Skip to content

Commit

Permalink
Update SmallRye Fault Tolerance to 5.5.0 and add Micrometer integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladicek committed Jul 11, 2022
1 parent 0025aff commit 6b61732
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Expand Up @@ -46,7 +46,7 @@
<smallrye-open-api.version>2.1.22</smallrye-open-api.version>
<smallrye-graphql.version>1.6.0</smallrye-graphql.version>
<smallrye-opentracing.version>2.1.0</smallrye-opentracing.version>
<smallrye-fault-tolerance.version>5.4.1</smallrye-fault-tolerance.version>
<smallrye-fault-tolerance.version>5.5.0</smallrye-fault-tolerance.version>
<smallrye-jwt.version>3.5.2</smallrye-jwt.version>
<smallrye-context-propagation.version>1.2.2</smallrye-context-propagation.version>
<smallrye-reactive-streams-operators.version>1.0.13</smallrye-reactive-streams-operators.version>
Expand Down
11 changes: 8 additions & 3 deletions docs/src/main/asciidoc/smallrye-fault-tolerance.adoc
Expand Up @@ -9,7 +9,7 @@ include::./attributes.adoc[]

One of the challenges brought by the distributed nature of microservices is that communication with external systems is
inherently unreliable. This increases demand on resiliency of applications. To simplify making more resilient
applications, Quarkus provides https://github.com/smallrye/smallrye-fault-tolerance/[SmallRye Fault Tolerance] an
applications, Quarkus provides https://github.com/smallrye/smallrye-fault-tolerance/[SmallRye Fault Tolerance], an
implementation of the https://github.com/eclipse/microprofile-fault-tolerance/[MicroProfile Fault Tolerance]
specification.

Expand Down Expand Up @@ -500,7 +500,7 @@ implementation("io.quarkus:quarkus-smallrye-fault-tolerance")
== Additional resources

SmallRye Fault Tolerance has more features than shown here.
Please check the link:https://smallrye.io/docs/smallrye-fault-tolerance/5.4.0/index.html[SmallRye Fault Tolerance documentation] to learn about them.
Please check the link:https://smallrye.io/docs/smallrye-fault-tolerance/5.5.0/index.html[SmallRye Fault Tolerance documentation] to learn about them.

In Quarkus, you can use the SmallRye Fault Tolerance optional features out of the box.

Expand Down Expand Up @@ -532,7 +532,12 @@ smallrye.faulttolerance.mp-compatibility=true
----
====

The link:https://smallrye.io/docs/smallrye-fault-tolerance/5.4.0/usage/programmatic-api.html[programmatic API] is present, including Mutiny support, and integrated with the declarative, annotation-based API.
The link:https://smallrye.io/docs/smallrye-fault-tolerance/5.5.0/usage/programmatic-api.html[programmatic API] is present, including Mutiny support, and integrated with the declarative, annotation-based API.
You can use the `FaultTolerance` and `MutinyFaultTolerance` APIs out of the box.

Support for Kotlin is present (assuming you use the Quarkus extension for Kotlin), so you can guard your `suspend` functions with fault tolerance annotations.

Metrics are automatically discovered and integrated.
If your application uses the Quarkus extension for Micrometer, SmallRye Fault Tolerance will emit metrics to Micrometer.
If your application uses the Quarkus extension for SmallRye Metrics, SmallRye Fault Tolerance will emit metrics to MicroProfile Metrics.
Otherwise, SmallRye Fault Tolerance metrics will be disabled.
Expand Up @@ -56,6 +56,7 @@
import io.quarkus.deployment.metrics.MetricsCapabilityBuildItem;
import io.quarkus.deployment.recording.RecorderContext;
import io.quarkus.gizmo.ClassOutput;
import io.quarkus.runtime.metrics.MetricsFactory;
import io.quarkus.smallrye.faulttolerance.runtime.QuarkusAsyncExecutorProvider;
import io.quarkus.smallrye.faulttolerance.runtime.QuarkusExistingCircuitBreakerNames;
import io.quarkus.smallrye.faulttolerance.runtime.QuarkusFallbackHandlerProvider;
Expand All @@ -72,7 +73,6 @@
import io.smallrye.faulttolerance.core.util.RunnableWrapper;
import io.smallrye.faulttolerance.internal.RequestContextControllerProvider;
import io.smallrye.faulttolerance.internal.StrategyCache;
import io.smallrye.faulttolerance.metrics.MetricsProvider;
import io.smallrye.faulttolerance.propagation.ContextPropagationRequestContextControllerProvider;
import io.smallrye.faulttolerance.propagation.ContextPropagationRunnableWrapper;

Expand Down Expand Up @@ -190,10 +190,18 @@ public void transform(TransformationContext context) {
StrategyCache.class,
QuarkusFallbackHandlerProvider.class,
QuarkusAsyncExecutorProvider.class,
MetricsProvider.class,
CircuitBreakerMaintenanceImpl.class,
RequestContextIntegration.class,
SpecCompatibility.class);

if (metricsCapability.isEmpty()) {
builder.addBeanClass("io.smallrye.faulttolerance.metrics.NoopProvider");
} else if (metricsCapability.get().metricsSupported(MetricsFactory.MP_METRICS)) {
builder.addBeanClass("io.smallrye.faulttolerance.metrics.MicroProfileMetricsProvider");
} else if (metricsCapability.get().metricsSupported(MetricsFactory.MICROMETER)) {
builder.addBeanClass("io.smallrye.faulttolerance.metrics.MicrometerProvider");
}

beans.produce(builder.build());

// TODO FT should be smart enough and only initialize the stuff in the recorder if it's really needed
Expand All @@ -205,11 +213,6 @@ public void transform(TransformationContext context) {
CdiFaultToleranceSpi.LazyDependencies.class)
.build());

if (!metricsCapability.isPresent()) {
//disable fault tolerance metrics with the MP sys props
systemProperty.produce(new SystemPropertyBuildItem("MP_Fault_Tolerance_Metrics_Enabled", "false"));
}

config.produce(new RunTimeConfigurationDefaultBuildItem("smallrye.faulttolerance.mp-compatibility", "false"));
}

Expand Down
2 changes: 1 addition & 1 deletion jakarta/rewrite.yml
Expand Up @@ -423,7 +423,7 @@ recipeList:
newValue: 3.0.0-RC2
- org.openrewrite.maven.ChangePropertyValue:
key: smallrye-fault-tolerance.version
newValue: 6.0.0-RC3
newValue: 6.0.0-RC4
- org.openrewrite.maven.ChangePropertyValue:
key: smallrye-graphql.version
newValue: 2.0.0.RC4
Expand Down

0 comments on commit 6b61732

Please sign in to comment.