-
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.
Merge pull request #7987 from Ladicek/opentracing-tests-and-fixes
fix OpenTracing trace context propagation with Fault Tolerance @asynchronous methods
- Loading branch information
Showing
11 changed files
with
133 additions
and
35 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
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