MicroProfile Fault Tolerance allows users to easily apply strategies for mitigating failures in their code. It provides annotations which you can add to methods to use bulkhead, circuit breaker, retry, timeout and fallback strategies.
The new mpFaultTolerance-4.1 feature provides integration with mpTelemetry-2.0 allowing Fault Tolerance to export metric data to Open Telemetry. With this change, and other changes in mpTelemetry-2.0 you can now use Open Telemetry as one single source for logging, metrics, and tracing, making it easier to manage and configure your application's observability.
To enable this functionality simply enable mpFaultTolerance-4.1 and mpTelemetry-2.0 in your server.xml then configure mpTelemetry-2.0 to export metrics. Here is a minimal configuration that will configure Open Telemetry to export to your messages.log file and a class which will generate Fault Tolerance metrics (it must be accessed as a CDI bean).
bootstrap.properties
This will configure Open Telemetry to only output metrics, you will find them in messages.log
otel.sdk.disabled=false
otel.metrics.exporter=logging
otel.logs.exporter=none
otel.traces.exporter=none
TODO; set the timeout to a low number so people will see the metrics quickly. Then mention why you did so in the paragraph apart
Example class
Ensure this class is injected as a CDI bean and invoked by the user in whatever way you prefer.
import org.eclipse.microprofile.faulttolerance.Retry;
import jakarta.enterprise.context.ApplicationScoped;
@ApplicationScoped
public class Example Class {
@Retry
public int exampleMethod(String name) {
return 1;
}
}
MicroProfile Fault Tolerance allows users to easily apply strategies for mitigating failures in their code. It provides annotations which you can add to methods to use bulkhead, circuit breaker, retry, timeout and fallback strategies.
The new
mpFaultTolerance-4.1
feature provides integration withmpTelemetry-2.0
allowing Fault Tolerance to export metric data to Open Telemetry. With this change, and other changes inmpTelemetry-2.0
you can now use Open Telemetry as one single source for logging, metrics, and tracing, making it easier to manage and configure your application's observability.To enable this functionality simply enable
mpFaultTolerance-4.1
andmpTelemetry-2.0
in your server.xml then configurempTelemetry-2.0
to export metrics. Here is a minimal configuration that will configure Open Telemetry to export to your messages.log file and a class which will generate Fault Tolerance metrics (it must be accessed as a CDI bean).server.xml
bootstrap.properties This will configure Open Telemetry to only output metrics, you will find them in messages.log
Example class Ensure this class is injected as a CDI bean and invoked by the user in whatever way you prefer.
Further resources:
You can learn more about how to use MicroProfile OpenAPI from our documentation and guide.