-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix OpenTracing trace context propagation with Fault Tolerance @async…
…hronous methods There used to be a test for that, but didn't involve `@Asynchronous` methods, so was in fact useless. This commit changes the test to actually call an `@Asynchronous` method, which revealed an issue. The `smallrye-fault-tolerance-tracing-propagation` dependency was missing, so trace context propagation didn't actually work. Then, the test also uncovered an issue in SmallRye Fault Tolerance (see smallrye/smallrye-fault-tolerance#208), which is why this commit also brings a new version of it. In addition to that, this commit also fixes a devmode issue where on hot reload, the Jaeger extension tried to register a gauge that was already present. That ended up with an exception. And finally, this commit also adds a test for tracing JDBC.
- Loading branch information
Showing
8 changed files
with
119 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 21 additions & 4 deletions
25
...ntracing/deployment/src/test/java/io/quarkus/smallrye/opentracing/deployment/Service.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,53 @@ | ||
package io.quarkus.smallrye.opentracing.deployment; | ||
|
||
import java.time.temporal.ChronoUnit; | ||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.CompletionStage; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
import javax.persistence.EntityManager; | ||
|
||
import org.eclipse.microprofile.faulttolerance.Asynchronous; | ||
import org.eclipse.microprofile.faulttolerance.Fallback; | ||
import org.eclipse.microprofile.faulttolerance.Retry; | ||
import org.eclipse.microprofile.faulttolerance.Timeout; | ||
import org.eclipse.microprofile.opentracing.Traced; | ||
|
||
import io.opentracing.Tracer; | ||
|
||
@Traced | ||
@ApplicationScoped | ||
public class Service { | ||
|
||
@Inject | ||
Tracer tracer; | ||
|
||
@Inject | ||
EntityManager em; | ||
|
||
@Traced | ||
public void foo() { | ||
} | ||
|
||
// @Asynchronous methods (and their fallback methods) shouldn't be @Traced | ||
// because https://github.com/eclipse/microprofile-opentracing/issues/189 | ||
@Asynchronous | ||
@Fallback(fallbackMethod = "fallback") | ||
@Timeout(value = 20L, unit = ChronoUnit.MILLIS) | ||
@Retry(delay = 10L, maxRetries = 2) | ||
public String faultTolerance() { | ||
public CompletionStage<String> faultTolerance() { | ||
tracer.buildSpan("ft").start().finish(); | ||
throw new RuntimeException(); | ||
} | ||
|
||
public String fallback() { | ||
return "fallback"; | ||
public CompletionStage<String> fallback() { | ||
tracer.buildSpan("fallback").start().finish(); | ||
return CompletableFuture.completedFuture("fallback"); | ||
} | ||
|
||
@Traced | ||
public List<Fruit> getFruits() { | ||
return em.createNamedQuery("Fruits.findAll", Fruit.class).getResultList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters