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:
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 |
* |
* 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;
}
};