Redis OpenTelemetry spans create new traces when using a custom SmallRye ManagedExecutor (Quarkus 3.37.2) #55463
Closed
GUMMADAPUSURESH
started this conversation in
Community
Replies: 2 comments 1 reply
|
I don't think you can use such a kind of executor with virtual threads. You need to use the proposed one that propagates the duplicated context. Did you try with the Quarkus virtual thread executor? |
1 reply
|
Thanks for the clarification and the detailed explanation. I've managed to achieve the desired behavior by using the Quarkus-managed virtual thread executor instead of creating my own Using the Quarkus-provided @ApplicationScoped
public class VirtualExecutorProducer {
private final ExecutorService quarkusVirtualExecutor;
public VirtualExecutorProducer(@VirtualThreads ExecutorService quarkusVirtualExecutor) {
this.quarkusVirtualExecutor = quarkusVirtualExecutor;
}
@Produces
@VirtualThreadsManaged // Custom CDI qualifier
public ManagedExecutor createVirtualManagedExecutor() {
return SmallRyeManagedExecutor.builder()
.withExecutorService(quarkusVirtualExecutor)
.propagated(ThreadContext.ALL_REMAINING)
.build();
}
} |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Redis OpenTelemetry spans create new traces when using a custom SmallRye ManagedExecutor (Quarkus 3.37.2)
Hi everyone,
I'm seeing unexpected OpenTelemetry tracing behavior with the Quarkus Redis client when using a custom
ManagedExecutor.Environment
quarkus-opentelemetryquarkus-smallrye-context-propagationquarkus-redis-clientScenario
I execute two asynchronous tasks using
CompletableFuture:Both tasks are executed using a
ManagedExecutor.Custom ManagedExecutor
I also reproduced the same behavior using:
instead of virtual threads, so the issue does not appear to be specific to virtual threads.
Async execution
Observations
Inside the async task:
Span.current().getSpanContext().isValid()istrueSpan.current().getSpanContext().getTraceId()matches the HTTP request tracetraceIdExample:
The trace ID remains the same before and after the Redis call.
Expected behavior
The Redis
CLIENTspan should be a child of the current HTTP request span.Actual behavior
In Jaeger:
GET,SET, andEXPIREoperations each appear as completely separate traces with their own trace IDs when using the customManagedExecutor.ManagedExecutoror my custom one, so I cannot compare MongoDB tracing behavior.Additional observations
ManagedExecutor:Redis spans are correctly linked to the parent HTTP request trace.
If I produce my own
SmallRyeManagedExecutor, the active OpenTelemetry context is still correct:Span.current()contains the expected trace ID.Despite this, Redis
CLIENTspans are emitted as independent root traces.I verified the same behavior with both:
Executors.newVirtualThreadPerTaskExecutor()Executors.newFixedThreadPool(...)Therefore, the issue does not appear to be related to virtual threads themselves.
Question
Is this expected behavior when creating a custom
SmallRyeManagedExecutorusingSmallRyeManagedExecutor.builder().withExecutorService(...), or is this a limitation/bug in the Quarkus Redis OpenTelemetry instrumentation?Has anyone encountered this before or knows if there is an officially supported way to use a custom
ManagedExecutor(or a customExecutorService) while preserving Redis tracing?All reactions