Metrics
SmallRye Fault Tolerance exposes 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 and OpenTelemetry support (as specified by MicroProfile Fault Tolerance), SmallRye Fault Tolerance also provides support for Micrometer. The set of metrics emitted to Micrometer is the same, using the same metric names and tags.
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;
}
};
Disabling Metrics
It is possible to completely disable fault tolerance metrics using MicroProfile Config:
smallrye.faulttolerance.metrics.enabled=false
# alternatively, a specification-defined property can be used
MP_Fault_Tolerance_Metrics_Enabled=false
It is also possible to disable individual metric providers:
# to disable MP Metrics
smallrye.faulttolerance.mpmetrics.disabled=true
# to disable OpenTelemetry Metrics
smallrye.faulttolerance.opentelemetry.disabled=true
# to disable Micrometer
smallrye.faulttolerance.micrometer.disabled=true
Note that setting smallrye.faulttolerance.*.disabled
to false
does not mean the provider is enabled unconditionally.
When that provider is not discovered or selected by the integrator, it cannot be enabled in any way.
These properties are only meant for disabling an otherwise enabled metrics provider; not the other way around.