Jaxrs: use scope when span is opened
@@ -3,6 +3,7 @@ package datadog.trace.instrumentation.jaxrs;
import static datadog.trace.instrumentation.jaxrs.JaxRsClientDecorator.DECORATE;
import datadog.trace.api.DDTags;
+import io.opentracing.Scope;
import io.opentracing.Span;
import io.opentracing.propagation.Format;
import io.opentracing.util.GlobalTracer;
@@ -21,12 +22,12 @@ public class ClientTracingFilter implements ClientRequestFilter, ClientResponseF
@Override
public void filter(final ClientRequestContext requestContext) {
-
final Span span =
GlobalTracer.get()
.buildSpan("jax-rs.client.call")
.withTag(DDTags.RESOURCE_NAME, requestContext.getMethod() + " jax-rs.client.call")
.start();
+ try (final Scope scope = GlobalTracer.get().scopeManager().activate(span, false)) {
DECORATE.afterStart(span);
DECORATE.onRequest(span, requestContext);
@@ -40,6 +41,7 @@ public class ClientTracingFilter implements ClientRequestFilter, ClientResponseF
requestContext.setProperty(SPAN_PROPERTY_NAME, span);
}
+ }
@Override
public void filter(
