/** * Count the thrown exception and put the stack trace in the details portion of the key. * This will allow the stack trace to be viewed in the JAMon web application. */ protected void trackException(MonKey key, Throwable ex) { String stackTrace = "stackTrace=" + Misc.getExceptionTrace(ex); key.setDetails(stackTrace); // Specific exception counter. Example: java.lang.RuntimeException MonitorFactory.add(new MonKeyImp(ex.getClass().getName(), stackTrace, "Exception"), 1); // General exception counter which is a total for all exceptions thrown MonitorFactory.add(new MonKeyImp(MonitorFactory.EXCEPTIONS_LABEL, stackTrace, "Exception"), 1); }
/** * 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); } } }
/** create a key from passed in label, details and units. note that details aren't really part of the key * * @param label Monitors key (Example: myUnixBackup) * @param detail Any string that you would want to access via a listener (Example: 400MB backup succeeded) * @param units Monitors unit (Example: minutes) * @return The monitors key */ private MonKey getMonKey(String label, String detail, String units) { if (detail==null) detail=label; return new MonKeyImp(label, detail, units); }
private MonKey createKey(String summaryLabel, String detailLabel, LoggingEvent event) { if (enableListenerDetails) // put array in details buffer return new Log4jMonKey(summaryLabel, detailLabel, units, event); else return new MonKeyImp(summaryLabel, detailLabel, units); }
public Monitor getTimeMonitor(String label) { return getTimeMonitor(new MonKeyImp(label, "ms."), NOT_PRIMARY); }
private void trackException(Throwable rootCause, Method method, String sqlMessage) { String detailStackTrace = Misc.getExceptionTrace(rootCause); MonitorFactory.add(new MonKeyImp(MonitorFactory.EXCEPTIONS_LABEL, detailStackTrace, "Exception"), 1); // counts total exceptions from jamon MonitorFactory.add(new MonKeyImp("MonProxy-Exception: InvocationTargetException", detailStackTrace, "Exception"), 1); //counts total exceptions for MonProxy MonitorFactory.add(new MonKeyImp("MonProxy-Exception: Root cause exception="+rootCause.getClass().getName()+sqlMessage, detailStackTrace, "Exception"), 1); // Message for the exception MonitorFactory.add(new MonKeyImp(labelerInt.getExceptionLabel(method), detailStackTrace,"Exception"), 1); // Exception and method that threw it. }
/** * Count the thrown exception and put the stack trace in the details portion of the key. * This will allow the stack trace to be viewed in the JAMon web application. */ protected void trackException(MonKey key, Throwable ex) { String stackTrace = "stackTrace=" + Misc.getExceptionTrace(ex); key.setDetails(stackTrace); // Specific exception counter. Example: java.lang.RuntimeException MonitorFactory.add(new MonKeyImp(ex.getClass().getName(), stackTrace, "Exception"), 1); // General exception counter which is a total for all exceptions thrown MonitorFactory.add(new MonKeyImp(MonitorFactory.EXCEPTIONS_LABEL, stackTrace, "Exception"), 1); }
/** * Count the thrown exception and put the stack trace in the details portion of the key. * This will allow the stack trace to be viewed in the JAMon web application. */ protected void trackException(MonKey key, Throwable ex) { String stackTrace = "stackTrace=" + Misc.getExceptionTrace(ex); key.setDetails(stackTrace); // Specific exception counter. Example: java.lang.RuntimeException MonitorFactory.add(new MonKeyImp(ex.getClass().getName(), stackTrace, "Exception"), 1); // General exception counter which is a total for all exceptions thrown MonitorFactory.add(new MonKeyImp(MonitorFactory.EXCEPTIONS_LABEL, stackTrace, "Exception"), 1); }
public TimeMon2() { super(new MonKeyImp("timer","ms."),new MonInternals()); monData.activityStats=new ActivityStats(); monData.isTimeMonitor=true; }
private void createSizeThresholdExceededMon(HttpMonRequest httpMonBase) { String label=new StringBuffer(httpMonBase.getLabelPrefix()).append(".HttpMonFactory.sizeExceeded.").append(httpMonBase.getSize()).toString(); String detailLabel=new StringBuffer(getLabel(httpMonBase)).append(", ").append(httpMonBase.getRequestURI()).append(", ").append(getUnits()).toString(); MonitorFactory.add(new MonKeyImp(label, detailLabel, "Count"), httpMonBase.getSize()); }
public Monitor add(String label, String units, double value) { return getMonitor(new MonKeyImp(label, units)).add(value); }
protected MonKeyImp mon(MonKeyImp monkey) { MonKeyImp m = (monkey.getLabel().startsWith(experimentName)) ? monkey : new MonKeyImp(experimentName + "_" + monkey.getLabel(), monkey.getUnits()); return m; }
@Override protected void trackException(JoinPoint jp, Throwable throwable) { AutomonExpirable exceptionContext = populateArgNamesAndValues_InExceptionContext(jp, throwable); // Multiple monitors are tracked for the exception such as one of the specific exception and one that represents // all exceptions. List<String> labels = getLabels(throwable); for (String label : labels) { MonKey key = new MonKeyImp(label, exceptionContext, "Exception"); MonitorFactory.add(key, 1); } }
@Override protected void trackException(JoinPoint jp, Throwable throwable) { AutomonExpirable exceptionContext = populateArgNamesAndValues_InExceptionContext(jp, throwable); // Multiple monitors are tracked for the exception such as one of the specific exception and one that represents // all exceptions. List<String> labels = getLabels(throwable); for (String label : labels) { MonKey key = new MonKeyImp(label, exceptionContext, "Exception"); MonitorFactory.add(key, 1); } }
protected MonKeyImp mon(MonKeyImp oldMonkey, int index) { // narrensicher MonKeyImp newMonkey = mon(oldMonkey); return new MonKeyImp(newMonkey.getLabel() + "_" + index, newMonkey.getUnits()); }
public TimeMon2() { super(new MonKeyImp("timer","ms."),new MonInternals()); monData.setActivityStats(new ActivityStats()); monData.isTimeMonitor=true; }
private Object executeMethod(HttpMonRequest httpMonBase) { Object retValue=null; try { retValue = getMethod(httpMonBase).invoke(getObjectToExecute(httpMonBase), (Object[])null);// null is noargs. } catch (Throwable e) {// note I don't want the program to abort due to monitoring so the exception is not being passed upstream MonitorFactory.add(new MonKeyImp(httpMonBase.getLabelPrefix()+".monError", new Object[]{this, Misc.getExceptionTrace(e)}, "Exception"),1); } return retValue; }
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(); } }