helidon
helidon copied to clipboard
Helidon SE: Active span is returning null from GlobalTracer for inbound requests
Environment Details
- Helidon Version:2.5.1
- Helidon SE
- JDK version: java version "17.0.3.1"
- OS: Mac OS Monterey 12.2.1
- Docker version (if applicable):
Problem Description
In Helidon SE application when intercepting inbound requests, activeSpan is returning null from GlobalTracer //: # "State if the problem is easily reproducible or happens intermittently" easily reproducible //: # "Include stack traces or command outputs"
Steps to reproduce
1.Create a sample Helidon SE application 2.Intercept any inbound request 3. GlobalTracer.get().scopeManager().activeSpan(); is returning null //: # "Provide sample code/application if relevant"
GlobalTracer.get().scopeManager().activeSpan();
@midhunnkj What dependencies do you have in your pom? Have you included Jaeger or Zipkin?
Hello, active span cannot be obtained from tracer, because it is reactive and may use multiple threads within a single request. To obtain the current span context, please use
io.helidon.common.context.Contexts.context()
.flatMap(it -> it.get(SpanContext.class))
.orElse(null);
or
serverRequest.context().get(SpanContext.class)
to obtain it. This can be used to create additional spans as children of it.