public void afterDeployment(@Observes AfterDeploymentValidation event) { if (delayedAutoStart) { etmMonitor.start(); } }
@Override public void filter(ContainerRequestContext requestContext) throws IOException { EtmPoint point = etmMonitor.createPoint("HTTP " + request.getMethod() + " request " + getPath()); request.setAttribute(JETM_JAXRS_POINT, point); }
public Object getAttribute(String string) throws AttributeNotFoundException, MBeanException, ReflectionException { if ("started".equals(string)) { return (etmMonitor.isStarted()) ? Boolean.TRUE : Boolean.FALSE; } else if ("collecting".equals(string)) { return (etmMonitor.isCollecting()) ? Boolean.TRUE : Boolean.FALSE; } else if ("startDate".equals(string)) { return (etmMonitor.getMetaData().getStartTime()); } else if ("lastResetDate".equals(string)) { return etmMonitor.getMetaData().getLastResetTime(); } else { throw new AttributeNotFoundException(string); } }
configurations.add(path.getName() + "!*"); plugin.setDestinations(configurations); monitor.addPlugin(plugin); monitor.start(); EtmPoint point = monitor.createPoint("testPoint"); try { Thread.sleep(2); monitor.stop();
public void stop() { monitor.stop(); }
public void testAutostartConfig() throws Exception { URL url = locateResource("autostart-on-config.xml"); EtmManager.reset(); XmlEtmConfigurator.configure(url); EtmMonitor etmMonitor = EtmManager.getEtmMonitor(); assertTrue(etmMonitor.isStarted()); assertTrue(etmMonitor.isCollecting()); etmMonitor.stop(); url = locateResource("autostart-off-config.xml"); EtmManager.reset(); XmlEtmConfigurator.configure(url); etmMonitor = EtmManager.getEtmMonitor(); assertFalse(etmMonitor.isStarted()); assertTrue(etmMonitor.isCollecting()); }
public void testMissingAggregator() { EtmMonitor monitor = new NestedMonitor(); Rrd4jPlugin plugin = new Rrd4jPlugin(); monitor.addPlugin(plugin); PrintStream writer = System.err; ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream tmpErr = new PrintStream(out); System.setErr(tmpErr); try { monitor.start(); tmpErr.flush(); String s = new String(out.toByteArray(), Charset.defaultCharset()); assertTrue(s.indexOf("NotifyingAggregator") > -1); } finally { System.setErr(writer); monitor.stop(); } }
public synchronized String showHtmlInfos() { try { monitor.render(textRenderer); return writer.toString(); } finally { writer.reset(); } }
/** * Enables performance monitoring using {@link etm.core.configuration.BasicEtmConfigurator}. * */ public void enableBasicConfig() { if (!EtmManager.getEtmMonitor().isStarted()) { BasicEtmConfigurator.configure(true); EtmManager.getEtmMonitor().start(); } else { LOG.warn("Etm subsystem already initialized. Ignoring init."); } }
public Date getStartTime() { return monitor.getMetaData().getStartTime(); }
/** * Create a point used for measurement. * * @param pointOwner * The {@link Class} of the class that owns the requested point instance. * @param methodSignature * The signature of the method in which the point is being used. * @return An {@link EtmPoint}. */ public static EtmPoint getPoint(final Class<?> pointOwner, final String methodSignature) { final EtmMonitor monitor = EtmManager.getEtmMonitor(); final String measurementName = pointOwner.getCanonicalName() + ": " + methodSignature; return monitor.isStarted() ? monitor.createPoint(measurementName) : new NoOpEtmPoint(measurementName); } }
public Map getAggregates(int topLevel, int nestedSize) { for (int i = 0; i < topLevel; i++) { EtmPoint parent = monitor.createPoint("Testpoint" + i); try { Thread.sleep((long) (10d * Math.random())); if (nestedSize > 1) { doNested(i, 0, nestedSize); } } catch (InterruptedException e) { // ignored } finally { parent.collect(); } } DummyRenderer renderer = new DummyRenderer(); monitor.render(renderer); //monitor.render(new SimpleTextRenderer()); return renderer.getPoints(); }
protected void setUp() throws Exception { monitor = new NestedMonitor(); HttpConsoleServerPlugin etmPlugin = new HttpConsoleServerPlugin(); monitor.addPlugin(etmPlugin); monitor.start(); // sleep shortly to let the console start Thread.sleep(100); TestPointGenerator testPointGenerator = new TestPointGenerator(monitor, false); testPointGenerator.getEtmPoints(5, 2); }
public boolean isStarted() { return monitor.isStarted(); }
public void testCollectionStart() throws Exception { // we stop our monitor and activate it using the console monitor.disableCollection(); executeRequest("/start"); assertTrue(monitor.isCollecting()); }
private static void addPlugins(EtmMonitor aEtmMonitor, List aPluginConfig) throws IllegalAccessException, InstantiationException, InvocationTargetException, ClassNotFoundException { for (int i = 0; i < aPluginConfig.size(); i++) { EtmPluginConfig etmPluginConfig = (EtmPluginConfig) aPluginConfig.get(i); Object obj = etmPluginConfig.getPluginClass().newInstance(); if (etmPluginConfig.getProperties() != null) { setProperties(obj, etmPluginConfig.getProperties()); } aEtmMonitor.addPlugin((EtmPlugin) obj); } }
public MBeanInfo getMBeanInfo() { if (etmMonitor.isCollecting()) { return activeInfo; } else { return inactiveInfo; } }