/** * 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); }
/** Returns any object that has a named key. In this keys case * 'label' and 'units' makes sense, but any values are acceptible. */ public Object getValue(String key) { if (LABEL_HEADER.equalsIgnoreCase(key)) return getLabel(); else if (UNITS_HEADER.equalsIgnoreCase(key)) return getUnits(); else if ("param".equalsIgnoreCase(key)) return getParam(); else if ("details".equalsIgnoreCase(key)) return getDetails(); else if ("instanceName".equalsIgnoreCase(key)) return getInstanceName(); else return null; }
public List getBasicRowData(List rowData) { rowData.add(getInstanceName()); rowData.add(getLabel()+", "+getUnits()); return rowData; }
key = new MonKeyImp(label, "ms."); mon = MonitorFactory.start(key); return ctx.proceed(); } catch (Exception e) { if (key != null) { key.setDetails(onException(ctx, label, e));
private void putRev(MonitorComposite mc, MonKeyImp m) { mcsMapRev.put(mc, m.getLabel()); }
public String getRangeKey() { return getUnits(); }
public List getDisplayHeader(List header) { return getHeader(header); }
public List getRowDisplayData(List rowData) { return getRowData(rowData); }
public List getRowData(List rowData) { rowData.add(getInstanceName()); rowData.add(getLabel()); rowData.add(getUnits()); return rowData; }
/** Wrap jamon calls around the invoked method. Also track exceptions if they are thrown */ public Object monitor(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { Object retVal = null; String label = keyHelper.getLabel(proceedingJoinPoint); String details = keyHelper.getDetails(proceedingJoinPoint); MonKeyImp key = new MonKeyImp(label, details, "ms."); Monitor mon = MonitorFactory.start(key); try { retVal = proceedingJoinPoint.proceed(); } catch (Throwable t) { String exceptionDetails = keyHelper.getDetails(proceedingJoinPoint, t); key.setDetails(exceptionDetails); trackException(t, exceptionDetails); throw t; } finally { mon.stop(); } return retVal; }
private MonitorComposite get(MonKeyImp m) { return mcsMap.get(mon(m).getLabel()); }
public String getRangeKey() { return getUnits(); }
public List getDisplayHeader(List header) { return getHeader(header); }
public List getRowDisplayData(List rowData) { return getRowData(rowData); }
/** * 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); } } }
/** Returns any object that has a named key. In this keys case * 'label' and 'units' makes sense, but any values are acceptible. */ public Object getValue(String key) { if (LABEL_HEADER.equalsIgnoreCase(key)) return getLabel(); else if (UNITS_HEADER.equalsIgnoreCase(key)) return getUnits(); else return null; }