Versions: 3.1.6 and 3.2.0 (works as expected in 3.1.5)
Using Micrometer OpenTelemetry bridge with W3C context propagation, with Webflux and actuator. Enable automatic reactor context propagation, in 3.2.0 this is is done by spring.reactor.context-propagation=auto.
Minimal reproduction of the issue:
1. Clone https://github.com/jamesmoessis/tracing-bug-demo
2. Run the main application
3. curl -H 'traceparent: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01' http://localhost:8080/hello
You will see that the controller errors out, returning 500 because the tracer.getCurrentSpan() returns null.
Message:
java.lang.NullPointerException: Cannot invoke "io.micrometer.tracing.Span.context()" because the return value of "io.micrometer.tracing.Tracer.currentSpan()" is null
Expected: the current span will be available and the trace ID will be returned by the controller. This is the behaviour if you change the SB version to 3.1.5. This seems to only happen when the handler returns a Mono or Flux.
Comment From: mhalbritter
Thanks for the report, I think this is a duplicate of https://github.com/spring-projects/spring-framework/issues/31706.