@Produces @VendorDefined private Timer produceTimer(MetricRegistry registry, InjectionPoint ip) { Metric metric = ip.getAnnotated().getAnnotation(Metric.class); return registry.timer(newMetadata(ip, metric, MetricType.TIMER)); }
timed.unit(), toTags(timed.tags())); registry.timer(meta); LOGGER.log(Level.FINE, () -> "### Registered timer " + metricName);
@Produces public Timer produceTimer(InjectionPoint injectionPoint) { return applicationRegistry.timer(AnnotationMetadata.buildProducerMetadata(injectionPoint)); }
public void timeMe() { Timer timer = metrics.timer("metricTest.test1.timer"); Timer.Context context = timer.time(); try { Thread.sleep((long) (Math.random() * 1000)); } catch (InterruptedException e) { } finally { context.stop(); } }
@Before public void initData() { if (isInitialized) { return; } globalTimer = registry.timer("test.longData.timer"); for (long i : SAMPLE_LONG_DATA) { globalTimer.update(i, TimeUnit.NANOSECONDS); } isInitialized = true; }
@Test @InSequence(2) public void testTime() throws Exception { Timer timer = registry.timer("testTime"); double beforeStartTime = System.nanoTime(); Context context = timer.time(); double afterStartTime = System.nanoTime(); Thread.sleep(1000); double beforeStopTime = System.nanoTime(); double time = context.stop(); double afterStopTime = System.nanoTime(); double delta = (afterStartTime - beforeStartTime) + (afterStopTime - beforeStopTime); Assert.assertEquals(beforeStopTime - beforeStartTime, time, delta); }
@Produces @VendorDefined private Timer produceTimer(MetricRegistry registry, InjectionPoint ip) { Metric metric = ip.getAnnotated().getAnnotation(Metric.class); return registry.timer(newMetadata(ip, metric, MetricType.TIMER)); }
@Test @InSequence(5) public void timesRunnableInstances() throws Exception { Timer timer = registry.timer("testRunnable"); final AtomicBoolean called = new AtomicBoolean(); timer.time(() -> called.set(true)); Assert.assertEquals(timer.getCount(), 1); Assert.assertEquals(called.get(), true); }
@Test @InSequence(4) public void timesCallableInstances() throws Exception { Timer timer = registry.timer("testCallable"); final String value = timer.time(() -> "one"); Assert.assertEquals(timer.getCount(), 1); Assert.assertEquals(value, "one"); }
"Response timer for " + instrumentationName, MetricType.TIMER, MetricUnits.NANOSECONDS); this.requestTimer = metricsRegistry.timer(timerMetadata);
int delaySeconds = 15; Timer timer = registry.timer("testRate");
break; case TIMER: addBean(afterBeanDiscovery, name, Timer.class, new MetricImpl(registration), applicationRegistry.timer(registration)); break; case COUNTER:
timed.unit(), toTags(timed.tags())); registry.timer(meta); LOGGER.log(Level.FINE, () -> "### Registered timer " + metricName);