open-telemetry / open-telemetry/opentelemetry-java-instrumentation
Span.current() is not propagating with Vertx virtual threads
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1.2k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 228
Description
Describe the bug
Hi Otel team,
My team builds an API using Vertx and we use the Java Auto Instrumentation Agent via the Kubernetes Operator.
We have recently switched over to using the new Vertx verticle virtual threading model, and our Span propagation is no longer working. We embellish the Span created by Netty by adding custom attributes, events, and change the default span name from the HTTP verb to the normalized route path. Inside our RoutingContext handlers, Span.current() now points to a no-op Span instead of the Netty span it was pointing to before we switched to virtual threads.
I've put together a thorough repro which demonstrates this behaviour, as well as showing it works with the standard threading model, as well as when manually confuring the OpenTelemetry SDK with Vertx and virtual threads.
Repro: https://github.com/cjbhaines/vertx-otel-span-repro
Please let me know if there is anything I can do to assist!
Thanks,
Chris
Steps to reproduce
See repro: https://github.com/cjbhaines/vertx-otel-span-repro
Expected behavior
Span.current() points to the span created by Netty in RoutingContext handlers.
Actual behavior
Span.current() points to a no-op span.
Javaagent or library instrumentation version
2.0.0
Environment
- OpenTelemetry Java Automatic Instrumentation Agent: 2.0.0
- OpenTelemetry Java SDK: 1.35.0
- Vertx version: 4.5.3
- Java Version:
- openjdk 21.0.2 2024-01-16 LTS
- OpenJDK Runtime Environment Corretto-21.0.2.13.1 (build 21.0.2+13-LTS)
- OpenJDK 64-Bit Server VM Corretto-21.0.2.13.1 (build 21.0.2+13-LTS, mixed mode, sharing)
- OS for repro: macOS 14.0 (23A344)
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked vertx-otel-span-repro and compare the standard threading model with Vertx virtual threads. Trace the Netty-created span into the RoutingContext handlers, focusing on where Span.current() becomes a no-op. Done means Span.current() returns the Netty span in virtual-thread handlers while preserving the existing behavior for standard threads.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, observability-sre
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100