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

ft.invocations.total

Type

  • MP Metrics: Counter

  • OpenTelemetry: LongCounter

  • Micrometer: Counter

Unit

None

Description

The number of times the method was called.

Tags

  • method - the fully qualified method name

  • result = [valueReturned|exceptionThrown] - whether the invocation returned a value or threw an exception

  • fallback = [applied|notApplied|notDefined] - applied if fallback was used, notApplied if a fallback is configured but was not used, notDefined if a fallback is not configured

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

ft.timer.scheduled

Type

  • MP Metrics: Gauge<Integer>

  • OpenTelemetry: LongUpDownCounter

  • Micrometer: Gauge

Unit

None

Description

The number of tasks that are currently scheduled (for future execution) on the timer.

Tags

  • id - the ID of the timer, to distinguish multiple timers in a multi-application environment

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:

MP_Fault_Tolerance_Metrics_Enabled=false