/** * Return hits/count of the passed in monitor if it exists otherwise return 0 * * @param label jamon label * @param units jamon units * @return count */ static long getCount(String label, String units) { if (MonitorFactory.exists(label, units)) { Monitor mon = MonitorFactory.getMonitor(label, units); return (long) mon.getHits(); } return 0; }
/** * * @param label jamon label * @param units jamon units * @param value string representing the date metric to return lastaccess, firstaccess. * @return The date associated with the jamon monitor */ static Date getDate(String label, String units, String value) { if (MonitorFactory.exists(label, units)) { Monitor mon = MonitorFactory.getMonitor(label, units); return (Date) mon.getValue(value); } return null; }
/** * Return the value of the passed in monitor if it exists otherwise return 0 * * @param label jamon label * @param units jamon units * @param value string representing the metric to return i.e. avg, hits etc. * @return the metric */ static double getDouble(String label, String units, String value) { if (MonitorFactory.exists(label, units)) { Monitor mon = MonitorFactory.getMonitor(label, units); return (Double) mon.getValue(value); } return 0.0; }
private JAMonBufferListener getExceptionBufferListener() { if (MonitorFactory.exists(MonitorFactory.EXCEPTIONS_LABEL, EXCEPTION)) { Monitor mon = MonitorFactory.getMonitor(MonitorFactory.EXCEPTIONS_LABEL, EXCEPTION); if (mon.hasListener("value", "FIFOBuffer")) { JAMonListener bufferListener = mon.getListenerType("value").getListener("FIFOBuffer"); if (bufferListener instanceof JAMonBufferListener) { return (JAMonBufferListener) bufferListener; } } } return null; }
private boolean sizeThresholdExceeded(HttpMonRequest httpMonBase) { // if number of jamon rows is greater than configured size (as well as size has been defined i.e. > 0) then don't create a monitor. // if the monitor already exists then you can proceed as no more monitors will be created. return MonitorFactory.getNumRows()>httpMonBase.getSize() && httpMonBase.getSize()>0 && !MonitorFactory.exists(getMonKey(httpMonBase)); }
/** * Return the first monitor that exists in the passed in list. * * @param jmxBeanProperties * @return The found monitor based on label, and units or null if none is found */ static Monitor getMonitor(List<JamonJmxBeanProperty> jmxBeanProperties) { for (JamonJmxBeanProperty jmxBeanProperty: jmxBeanProperties) { if (MonitorFactory.exists(jmxBeanProperty.getLabel(), jmxBeanProperty.getUnits())) { return MonitorFactory.getMonitor(jmxBeanProperty.getLabel(), jmxBeanProperty.getUnits()); } } return null; }
@Override public String getMostRecentException() { if (!MonitorFactory.exists(LABEL, UNITS)) { return "No exceptions have been thrown"; } if (!MonitorFactory.getMonitor(LABEL, UNITS).hasListener("value", "FIFOBuffer")) { return "Exception Stacktrace tracking is not enabled."; } JAMonListener listener = MonitorFactory.getMonitor(LABEL, UNITS).getListenerType("value").getListener("FIFOBuffer"); if (!(listener instanceof JAMonBufferListener) || ((JAMonBufferListener) listener).isEmpty()) { return "There are no stacktraces"; } return getMostRecentStacktrace((JAMonBufferListener) listener); }