-
Notifications
You must be signed in to change notification settings - Fork 33
Description
I believe we're seeing an issue using opentracing-contrib:java-jaxrx:0.1.4, io.zipkin.brave:brave:4.19.2 and brave-opentracing-0.30.3 (all of this inside Dropwizard 1.2), however I'm very new to open tracing in and the available Java tracers and I'm hoping someone here can point me in the right direction:
The active span is not being cleared across requests and all spans that are created in requests are being tagged to the parent thread created in the first request to the server.
On this line the finishing filter pulls the active scope via the tracer's scope manager.
This active scope is closed via it's close() method. This eventually calls this close implementation in the BraveScopeManager. This scope manager has a noop close implementation and thus the scope remains open.
Then in later requests the JAXRS filter grabs the active span. On subsequent requests the active span is set to span that was created during the first request and all traces end up being children of the first trace ever created.
I'm unsure of the relation between Spans and Scopes in this situation but we've confirmed that the active span is being reused across all requests.
For context this is how we are initializing our filters:
AsyncReporter<Span> reporter = AsyncReporter.builder(sender).build();
Tracer tracer = BraveTracer
.newBuilder(
Tracing.newBuilder()
.localServiceName(openTracingConfig.getServiceName())
.spanReporter(reporter)
.sampler(Sampler.ALWAYS_SAMPLE)
.build()
)
.build();
GlobalTracer.register(tracer);
// Register feature / servlet filter to start traces
environment.jersey().register(
new ServerTracingDynamicFeature.Builder(tracer).build()
);
// Register filter to end traces
FilterRegistration.Dynamic registration = environment.servlets()
.addFilter("tracing-filter", new SpanFinishingFilter(tracer));
registration.setAsyncSupported(true);
registration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "*");