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); }