use of com.netflix.servo.monitor.BasicTimer in project incubator-servicecomb-java-chassis by apache.
the class MonitorManager method getTimer.
public Timer getTimer(String name, String... tags) {
validateMonitorNameAndTags(name, tags);
return timers.computeIfAbsent(getMonitorKey(name, tags), f -> {
Timer timer = new BasicTimer(getConfig(name, tags));
basicMonitorRegistry.register(timer);
return timer;
});
}
use of com.netflix.servo.monitor.BasicTimer in project tutorials by eugenp.
the class MetricTypeTest method givenTimer_whenExecuteTask_thenTimerUpdated.
@Test
public void givenTimer_whenExecuteTask_thenTimerUpdated() throws Exception {
BasicTimer timer = new BasicTimer(MonitorConfig.builder("test").build(), MILLISECONDS);
Stopwatch stopwatch = timer.start();
MILLISECONDS.sleep(1);
timer.record(2, MILLISECONDS);
stopwatch.stop();
assertEquals("timer should count 1 millisecond", 1, timer.getValue().intValue());
assertEquals("timer should count 3 millisecond in total", 3, timer.getTotalTime().intValue());
assertEquals("timer should record 2 updates", 2, timer.getCount().intValue());
assertEquals("timer should have max 2", 2, timer.getMax(), 0.01);
}
Aggregations