/** * Wraps the invocation with a JAMon Monitor and writes the current * performance statistics to the log (if enabled). * @see com.jamonapi.MonitorFactory#start * @see com.jamonapi.Monitor#stop */ @Override protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable { String name = createInvocationTraceName(invocation); MonKey key = new MonKeyImp(name, name, "ms."); Monitor monitor = MonitorFactory.start(key); try { return invocation.proceed(); } catch (Throwable ex) { trackException(key, ex); throw ex; } finally { monitor.stop(); if (!this.trackAllInvocations || isLogEnabled(logger)) { writeToLog(logger, "JAMon performance statistics for method [" + name + "]:\n" + monitor); } } }
/** * Adds the monitor. * * @param label the label */ public static void addMonitor(String label) { MonitorFactory.start(label); }
/** start a monitor and put it in the map so it can be retrieved when stop or skip are called. note add doesn't * need the monitor in the map. */ private void startMon(MonKey key) { map.put(key, MonitorFactory.start(key)); }
public void factoryMonitor() throws Exception { System.out.println("\nFull Factory TimingMonitor()- uses cached version so doesn't create child monitors"); System.out.println("\tMonitor mon=MonitorFactory.start('pages.admin');"); System.out.println("\tmon.stop();"); for (int i=0; i<testIterations; i++) { testMon=MonitorFactory.start("pages.admin"); testMon.stop(); } System.out.println(testMon); }
@Override public Monitor start(JoinPoint.StaticPart jp) { return MonitorFactory.start(jp.toString()); }
/** * Start. * * @param label the label * * @return the profile monitor */ public static ProfileMonitor start(String label) { Monitor mon = MonitorFactory.start(label); return new JamonMonitor(mon); }
public void factoryMonitor() throws Exception { System.out.println("\nFull Factory TimingMonitor()- uses cached version so doesn't create child monitors"); System.out.println("\tMonitor mon=MonitorFactory.start('pages.admin');"); System.out.println("\tmon.stop();"); for (int i=0; i<testIterations; i++) { testMon=MonitorFactory.start("pages.admin"); testMon.stop(); } System.out.println(testMon); }
public void factoryBasicMonitor() throws Exception { System.out.println("\nbasic Factory TimingMonitor()"); System.out.println("\tMonitor mon=MonitorFactory.start();"); System.out.println("\tmon.stop();"); //testMon=new TimingMonitor(); the following has the same performance characteristics but you also // have the added option of disabling the service and returning a null monitor for (int i=0; i<testIterations; i++) { testMon=MonitorFactory.start(); testMon.stop(); } }
public void factoryBasicMonitor() throws Exception { System.out.println("\nbasic Factory TimingMonitor()"); System.out.println("\tMonitor mon=MonitorFactory.start();"); System.out.println("\tmon.stop();"); //testMon=new TimingMonitor(); the following has the same performance characteristics but you also // have the added option of disabling the service and returning a null monitor for (int i=0; i<testIterations; i++) { testMon=MonitorFactory.start(); testMon.stop(); } }
Monitor startTimeMon(HttpMonRequest httpMonBase) { return MonitorFactory.start(getMonKey(httpMonBase)); }
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable { String name = createInvocationTraceName(invocation); Monitor monitor = MonitorFactory.start(name); try { return invocation.proceed(); } finally { monitor.stop(); logger.trace("JAMon performance statistics for method [" + name + "]:\n" + monitor); } }
public void nullMonitor() throws Exception { // The null monitor has the best possible performance, however it doesn't do anything so is only appropriate when monitoring // is disabled. System.out.println("\nNullMonitor() - Factory disabled so a NullMonitor is returned"); System.out.println("\tMonitorFactory.setEnabled(false);"); System.out.println("\tMonitor mon=MonitorFactory.start();"); System.out.println("\tmon.stop()"); MonitorFactory.setEnabled(false); for (int i=0; i<testIterations; i++) { testMon=MonitorFactory.start(); testMon.stop(); } MonitorFactory.setEnabled(true); }
public void nullMonitor2() throws Exception { // The null monitor has the best possible performance System.out.println("\nNullMonitor2() - Factory disabled so a NullMonitor is returned"); System.out.println("\tMonitorFactory.setEnabled(false);"); System.out.println("\tMonitor mon=MonitorFactory.start('pages.admin');"); System.out.println("\tmon.stop()"); MonitorFactory.setEnabled(false); for (int i=0; i<testIterations; i++) { testMon=MonitorFactory.start("pages.admin"); testMon.stop(); } MonitorFactory.setEnabled(true); }
/** * Start the monitor. */ public void start() { if(this.isActive) { MethodToStringBuilderImpl methodToStringBuilder = new MethodToStringBuilderImpl(this.method, 0); String methodSignature = methodToStringBuilder.toString(); this.monitor = MonitorFactory.start(methodSignature); } }
/** * Start the monitor. */ public void start() { if(this.isActive) { MethodToStringBuilderImpl methodToStringBuilder = new MethodToStringBuilderImpl(this.method, 0); String methodSignature = methodToStringBuilder.toString(); this.monitor = MonitorFactory.start(methodSignature); } }
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { Monitor allPages = MonitorFactory.start(new MonKeyImp("com.jamonapi.allPages",getURI(request),"ms.")); Monitor monitor = MonitorFactory.start(getURI(request)); try { filterChain.doFilter(request, response); } finally { monitor.stop(); allPages.stop(); } }
/** Called as part of the standard servlet contract before a page is requested. It is a hook point for JAMon to track metrics */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { Monitor allPages = MonitorFactory.start(new MonKeyImp("com.jamonapi.allPages",getURI(request),"ms.")); Monitor monitor = MonitorFactory.start(getURI(request)); try { filterChain.doFilter(request, response); } finally { monitor.stop(); allPages.stop(); } }
/** * Run the code in a new thread took from a thread pool. * * @param invocation * The code to run * @return The future object, to know when the task is completed */ public static Future<?> invoke(Invocation invocation) { Monitor monitor = MonitorFactory.getMonitor("Invoker queue size", "elmts."); monitor.add(executor.getQueue().size()); invocation.waitInQueue = MonitorFactory.start("Waiting for execution"); return executor.submit(invocation); }
@Override public void remove(String instanceKey) { localJamonData.remove(instanceKey); Monitor mon = MonitorFactory.start(getJamonLabel(".remove()")); try { jamonDataPersister.remove(instanceKey); } catch(Throwable t) { MonitorFactory.addException(mon, t); } finally { mon.stop(); } }