From 80185f76f405e61412d53f4005d709116fc4c8c0 Mon Sep 17 00:00:00 2001 From: Tyler Benson Date: Tue, 17 Sep 2019 11:35:10 -0700 Subject: [PATCH] Enable async propagation in JAX annotation span --- .../jaxrs/JaxRsAnnotationsInstrumentation.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dd-java-agent/instrumentation/jax-rs-annotations/src/main/java/datadog/trace/instrumentation/jaxrs/JaxRsAnnotationsInstrumentation.java b/dd-java-agent/instrumentation/jax-rs-annotations/src/main/java/datadog/trace/instrumentation/jaxrs/JaxRsAnnotationsInstrumentation.java index 20aa86fda9..6965525da0 100644 --- a/dd-java-agent/instrumentation/jax-rs-annotations/src/main/java/datadog/trace/instrumentation/jaxrs/JaxRsAnnotationsInstrumentation.java +++ b/dd-java-agent/instrumentation/jax-rs-annotations/src/main/java/datadog/trace/instrumentation/jaxrs/JaxRsAnnotationsInstrumentation.java @@ -9,6 +9,7 @@ import static net.bytebuddy.matcher.ElementMatchers.named; import com.google.auto.service.AutoService; import datadog.trace.agent.tooling.Instrumenter; +import datadog.trace.context.TraceScope; import io.opentracing.Scope; import io.opentracing.Tracer; import io.opentracing.util.GlobalTracer; @@ -64,6 +65,11 @@ public final class JaxRsAnnotationsInstrumentation extends Instrumenter.Default // Rename the parent span according to the path represented by these annotations. final Scope parent = tracer.scopeManager().active(); final Scope scope = tracer.buildSpan(JAX_ENDPOINT_OPERATION_NAME).startActive(true); + + if (scope instanceof TraceScope) { + ((TraceScope) scope).setAsyncPropagation(true); + } + DECORATE.onControllerStart(scope, parent, method); return DECORATE.afterStart(scope); }