About
A Timer is a metrics type that sends two values:
- an integer: the count of events during the interval (to measure throughput)
- a duration: the interval duration (to measure latency ie Total time / count).
Example
Suppose:
- we configure publishing at 10-second intervals
- we saw 20 requests that each took 100ms.
Then for the first interval:
- count = 10 seconds * (20 requests / 10 seconds) = 20 requests
- total-time = 10 seconds * (20 * 100 ms / 10 seconds) = 2 seconds
Therefore:
- Rate: total-time/count = 10 requests / second
Type
Background Task
As a timer reports the total time, a timer may not send any record until the task is complete.
Interval
A timer may be calculated at intervals.
Library
Micrometer
Timer timer = Timer
.builder("my.timer")
.description("a description of what this timer does")
.register(registry);
vertx.setPeriodic(1000, l -> {
timer.record(() -> {
// Running here some operation to monitor
});
});