quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.36k stars 2.56k forks source link

OTEL eventbus context #41290

Open appiepollo14 opened 2 weeks ago

appiepollo14 commented 2 weeks ago

Describe the bug

When using the vertx eventbus in combination with the quarkus opentelemetry extension, all context is lost within the eventConsumer. I'm not sure wether this should work, but looking at this code, I would expect so. So please either help me with a sample implementation on how to use the OTEL context through the eventbus or fix the issue.

I've made a reproducer. You can see the system output with the context in the @EventConsumer method to be empty.

Expected behavior

I expect the OTEL context to be passed into the Vertx eventbus to be used in the eventconsumer method.

Actual behavior

The OTEL context is empty.

How to Reproduce?

No response

Output of uname -a or ver

Darwin xxx.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64

Output of java -version

OpenJDK 64-Bit Server VM GraalVM CE 21+35.1 (build 21+35-jvmci-23.1-b15, mixed mode, sharing)

Quarkus version or git rev

3.11.2

Build tool (ie. output of mvnw --version or gradlew --version)

3.9.6

Additional information

No response

quarkus-bot[bot] commented 2 weeks ago

/cc @brunobat (opentelemetry,tracing), @radcortez (opentelemetry,tracing)

brunobat commented 2 weeks ago

As far as I can tell you need to use the Mutiny EventBus for this, because of the context propagation.

Please see test for the EventBusInstrumenterVertxTracer: https://github.com/quarkusio/quarkus/blob/ebee0a4b66d1b4dba9c51165e78d22fbf3b90d3e/integration-tests/opentelemetry-vertx/src/main/java/io/quarkus/it/opentelemetry/vertx/HelloRouter.java#L24 and here: https://github.com/quarkusio/quarkus/blob/fb79c7c22ee746c904a95199390e295865024f73/integration-tests/opentelemetry-vertx/src/test/java/io/quarkus/it/opentelemetry/vertx/HelloRouterTest.java#L110

appiepollo14 commented 2 weeks ago

Thanks @brunobat Even with the mutiny eventbus, I still get no context passed through the eventbus IMO. See this reproducer.

Still an issue due to misuse or is this a bug?

brunobat commented 1 week ago

I'm not sure what you are trying to do on the reproducer. Can you please start with the example we have in the tests?