Metrics

SmallRye Fault Tolerance provides support for MicroProfile Metrics, OpenTelemetry and Micrometer. Alternatively, metrics may be completely disabled at the integration level.

As usual, this integration is based on CDI. SmallRye Fault Tolerance includes an internal interface MetricsProvider and these implementations:

  • io.smallrye.faulttolerance.metrics.MicroProfileMetricsProvider

  • io.smallrye.faulttolerance.metrics.OpenTelemetryProvider

  • io.smallrye.faulttolerance.metrics.MicrometerProvider

  • io.smallrye.faulttolerance.metrics.NoopProvider

There are 2 possible ways how to integrate metrics:

  • exactly 1 class from the list above is a bean;

  • more than 1 class from the list above is a bean, in which case, io.smallrye.faulttolerance.metrics.CompoundMetricsProvider must also be a bean.

Only the names of the classes listed above are treated as public. That is, the classes should be treated as opaque, no guarantees about their internals are made.

Default Integration

In case the integrator uses the CDI Portable Extension FaultToleranceExtension and lets the container create an instance, metrics presence is discovered automatically. All present metrics systems are used.

Using a FaultToleranceExtension Constructor

In case the integrator uses the CDI Portable Extension FaultToleranceExtension and creates its instance manually, they can use a constructor.

In addition to a zero-parameter constructor, which is used in the default integration as described above, there are constructors that take a parameter of MetricsIntegration or Set<MetricsIntegration>.

MetricsIntegration is an enum with these values:

  • MICROPROFILE_METRICS: use MicroProfile Metrics integration

  • OPENTELEMETRY: use OpenTelemetry (MicroProfile Telemetry) integration

  • MICROMETER: use Micrometer integration

  • NOOP: no metrics

Metrics Providers

Metrics providers have additional requirements, as described below.

MicroProfile Metrics

If MicroProfile Metrics should be used, the integrator must ensure that the following artifacts are present:

  • org.eclipse.microprofile.metrics:microprofile-metrics-api;

  • some implementation of MicroProfile Metrics.

OpenTelemetry

If OpenTelemetry should be used, the integrator must ensure that the following artifact is present:

  • io.opentelemetry:opentelemetry-api.

Further, a bean of type io.opentelemetry.api.metrics.Meter must exist. This bean is used to emit the actual metrics.

Micrometer

If Micrometer should be used, the integrator must ensure that the following artifact is present:

  • io.micrometer:micrometer-core.

Further, a bean of type io.micrometer.core.instrument.MeterRegistry must exist. This bean is used to emit the actual metrics.

Noop

If the "noop" provider is used, metrics are completely disabled and the MP_Fault_Tolerance_Metrics_Enabled configuration property is ignored at runtime.

No metrics API and implementation is required in this case.