use of io.micrometer.core.instrument.LongTaskTimer in project micrometer by micrometer-metrics.
the class LongTaskTimerTest method record.
@Test
@DisplayName("total time is preserved for a single timing")
default void record(MeterRegistry registry) {
LongTaskTimer t = registry.more().longTaskTimer("myTimer");
LongTaskTimer.Sample sample = t.start();
clock(registry).add(10, TimeUnit.NANOSECONDS);
assertAll(() -> assertEquals(10, t.duration(TimeUnit.NANOSECONDS)), () -> assertEquals(0.01, t.duration(TimeUnit.MICROSECONDS)), () -> assertEquals(10, sample.duration(TimeUnit.NANOSECONDS)), () -> assertEquals(0.01, sample.duration(TimeUnit.MICROSECONDS)), () -> assertEquals(1, t.activeTasks()));
clock(registry).add(10, TimeUnit.NANOSECONDS);
sample.stop();
assertAll(() -> assertEquals(0, t.duration(TimeUnit.NANOSECONDS)), () -> assertEquals(-1, sample.duration(TimeUnit.NANOSECONDS)), () -> assertEquals(0, t.activeTasks()));
}
Aggregations