@Override public Void call() throws Exception { MetricsFactory.getInstance().startStoredScope("method2"); MetricsFactory.getInstance().endStoredScope("method2"); return null; } });
@Test public void testScope() throws Exception { int runs = 5; for (int i = 0; i < runs; i++) { MetricsFactory.getInstance().startStoredScope("method1"); MetricsFactory.getInstance().endStoredScope("method1"); Timer timer = metricRegistry.getTimers().get("method1"); Assert.assertEquals(i + 1, timer.getCount()); } Timer timer = metricRegistry.getTimers().get("method1"); Assert.assertTrue(timer.getMeanRate() > 0); }