Search in sources :

Example 1 with BasicTimer

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;
    });
}
Also used : BasicTimer(com.netflix.servo.monitor.BasicTimer) Timer(com.netflix.servo.monitor.Timer) BasicTimer(com.netflix.servo.monitor.BasicTimer)

Example 2 with BasicTimer

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);
}
Also used : BasicTimer(com.netflix.servo.monitor.BasicTimer) Stopwatch(com.netflix.servo.monitor.Stopwatch) Test(org.junit.Test)

Aggregations

BasicTimer (com.netflix.servo.monitor.BasicTimer)2 Stopwatch (com.netflix.servo.monitor.Stopwatch)1 Timer (com.netflix.servo.monitor.Timer)1 Test (org.junit.Test)1