Merge pull request #999 from DataDog/tyler/add-async-jax

Enable async propagation in JAX annotation span
This commit is contained in:
Tyler Benson 2019-09-17 14:31:02 -07:00 committed by GitHub
commit 153f88716b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
import com.google.auto.service.AutoService; import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter; import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.context.TraceScope;
import io.opentracing.Scope; import io.opentracing.Scope;
import io.opentracing.Tracer; import io.opentracing.Tracer;
import io.opentracing.util.GlobalTracer; 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. // Rename the parent span according to the path represented by these annotations.
final Scope parent = tracer.scopeManager().active(); final Scope parent = tracer.scopeManager().active();
final Scope scope = tracer.buildSpan(JAX_ENDPOINT_OPERATION_NAME).startActive(true); final Scope scope = tracer.buildSpan(JAX_ENDPOINT_OPERATION_NAME).startActive(true);
if (scope instanceof TraceScope) {
((TraceScope) scope).setAsyncPropagation(true);
}
DECORATE.onControllerStart(scope, parent, method); DECORATE.onControllerStart(scope, parent, method);
return DECORATE.afterStart(scope); return DECORATE.afterStart(scope);
} }