Metrics
SmallRye Fault Tolerance exposes metrics to MicroProfile Metrics, as specified by MicroProfile Fault Tolerance.
General Metrics
For all methods guarded with some fault tolerance strategy, the following metric is emitted:
Name |
|
Type |
|
Unit |
None |
Description |
The number of times the method was called. |
Tags |
|
For asynchronous methods, "value returned" means that the CompletionStage
completed successfully, while "exception thrown" means that the CompletionStage
completed exceptionally.
Specific Metrics
In addition to the general metrics described above, most fault tolerance strategies emit their own metrics. Those are described in the reference guides:
Timer Metrics
For task scheduling purposes (e.g. watching timeouts or delaying retries), SmallRye Fault Tolerance maintains one thread called the timer thread. Most of the time, it is kept sleeping (parked), it only wakes up (unparks) when necessary to submit tasks to executors.
The behavior of the timer thread can be observed through the following metrics:
Name |
|
Type |
|
Unit |
None |
Description |
The number of tasks that are currently scheduled (for future execution) on the timer. |
Tags |
|
Micrometer Support
In addition to the MicroProfile Metrics support, SmallRye Fault Tolerance also provides support for Micrometer. The set of metrics emitted to Micrometer is the same as the set of metrics emitted to MicroProfile Metrics, using the same metric names and tags. Metric types are mapped as closely as possible:
Name | MicroProfile Metrics | Micrometer | Note |
---|---|---|---|
|
counter |
counter |
|
|
counter |
counter |
|
|
counter |
counter |
|
|
counter |
counter |
|
|
histogram |
timer |
|
|
counter |
counter |
|
|
gauge |
time gauge |
|
|
gauge |
gauge |
* |
|
counter |
counter |
|
|
counter |
counter |
|
|
gauge |
gauge |
|
|
gauge |
gauge |
|
|
histogram |
timer |
|
|
histogram |
timer |
|
|
counter |
counter |
* |
|
gauge |
gauge |
* |
* This is a SmallRye Fault Tolerance feature, not specified by MicroProfile Fault Tolerance.
Note that distribution summaries in Micrometer, including timers, do not emit quantiles by default.
Micrometer recommends that libraries should not configure them out of the box, so if you need them, you should use a MeterFilter
.
The following implementation makes sure Micrometer emits the same quantiles as MicroProfile Metrics for all fault tolerance metrics:
static final MeterFilter ENABLE_HISTOGRAMS = new MeterFilter() {
@Override
public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticConfig config) {
if (id.getName().startsWith("ft.")) {
return DistributionStatisticConfig.builder()
.percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999)
.build()
.merge(config);
}
return config;
}
};