@Override public void sessionDestroyed(HttpSessionEvent se) { Stagemonitor.getMetric2Registry().counter(METRIC_NAME).dec(); } }
public RequestMonitor getRequestMonitor() { if (requestMonitor == null) { requestMonitor = new RequestMonitor(Stagemonitor.getConfiguration(), Stagemonitor.getMetric2Registry()); } return requestMonitor; }
@Advice.OnMethodEnter public static Timer.Context startTimer(@TimedSignature String signature) { return Stagemonitor.getMetric2Registry().timer(getTimerName(signature)).time(); }
private void assertOneMeterExists(MetricName timerName) { final Metric2Registry metricRegistry = Stagemonitor.getMetric2Registry(); assertEquals(1, metricRegistry.getMeters().size()); assertEquals(timerName, metricRegistry.getMeters().keySet().iterator().next()); }
@Test public void testMeteredAspectPrivate() { testObject.meteredPrivate(); assertEquals(1, Stagemonitor.getMetric2Registry().getMeters().size()); }
@Test public void testExceptionMeteredAspectexceptionMeteredPrivate() { try { testObject.exceptionMeteredPrivate(); } catch (Exception e) { // ignore } assertEquals(1, Stagemonitor.getMetric2Registry().getMeters().size()); }
@Test public void testTimedAspectPrivate() { testObject.timedPrivate(); assertEquals(1, Stagemonitor.getMetric2Registry().getTimers().size()); }
@Before public void setUp() throws Exception { metric2Registry = Stagemonitor.getMetric2Registry(); metric2Registry.removeMatching(MetricFilter.ALL); try (final Connection connection = dataSource.getConnection()) { connection.prepareStatement("CREATE TABLE IF NOT EXISTS STAGEMONITOR (FOO INT)").execute(); connection.prepareStatement("INSERT INTO STAGEMONITOR (FOO) VALUES (1)").execute(); } requestMonitor = Stagemonitor.getPlugin(TracingPlugin.class).getRequestMonitor(); configuration = Stagemonitor.getConfiguration(); testDao = new TestDao(dataSource); }
@Test public void testExceptionMeteredNoException() { try { testObject.exceptionMeteredNoException(); } catch (Exception e) { // ignore } final Metric2Registry metricRegistry = Stagemonitor.getMetric2Registry(); assertEquals(0, metricRegistry.getMeters().size()); }
@Before @After public void clearMetricRegistry() { Stagemonitor.getMetric2Registry().removeMatching(MetricFilter.ALL); }
@Test public void testExceptionMeteredCauseSupertype() { try { testObject.exceptionMeteredCauseSupertype(); } catch (Exception e) { // ignore } final Metric2Registry metricRegistry = Stagemonitor.getMetric2Registry(); assertEquals(metricRegistry.getMeters().toString(), 0, metricRegistry.getMeters().size()); }
@Before @After public void clearMetricRegistry() { Stagemonitor.getMetric2Registry().removeMatching(MetricFilter.ALL); }
@Test public void testExceptionMeteredCauseNoException() { try { testObject.exceptionMeteredCauseNoException(); } catch (Exception e) { // ignore } final Metric2Registry metricRegistry = Stagemonitor.getMetric2Registry(); assertEquals(0, metricRegistry.getMeters().size()); }
@Before @After public void clearMetricRegistry() { Stagemonitor.getMetric2Registry().removeMatching(MetricFilter.ALL); }
@AfterClass public static void cleanUp() { GlobalTracerTestHelper.resetGlobalTracer(); Stagemonitor.reset(); Stagemonitor.getMetric2Registry().removeMatching(MetricFilter.ALL); }
public static void main(String[] args) throws Exception { final Timer.Context timer = Stagemonitor.getMetric2Registry().timer(name("startElasticsearch").build()).time(); startElasticsearch(); Stagemonitor.init(); timer.stop(); printResults(); node.close(); }
@After public void tearDown() throws Exception { assertThat(tracer.scopeManager().active()).isNull(); Stagemonitor.getMetric2Registry().removeMatching(Metric2Filter.ALL); Stagemonitor.reset(); }
@Test public void testLogging() throws Exception { logger.error("test"); final Map<MetricName, Meter> meters = Stagemonitor.getMetric2Registry().getMeters(); assertNotNull(meters.get(name("logging").tag("log_level", "error").build())); assertEquals(1, meters.get(name("logging").tag("log_level", "error").build()).getCount()); } }
@After public void after() { Stagemonitor.getMetric2Registry().removeMatching(Metric2Filter.ALL); Stagemonitor.reset(); assertThat(tracingPlugin.getTracer().scopeManager().active()).isNull(); } }
@Test public void testGaugeAspectDefault() { final Metric2Registry metricRegistry = Stagemonitor.getMetric2Registry(); assertThat(metricRegistry.getGauges().keySet()).contains( name("gauge_GaugeTestObject#gaugeDefault").build(), name("gauge_GaugeTestObject#staticGaugeDefault").build(), name("gauge_gaugeAbsolute").build(), name("gauge_GaugeTestObject#myGaugeName").build(), name("gauge_myGaugeNameAbsolute").build() ); } }