Make spring controller spans to handle async

This commit is contained in:
Luca Abbati 2019-05-24 17:42:06 +02:00
parent 200a9063fa
commit 25e06b4965
No known key found for this signature in database
GPG Key ID: C901DDA2FFE14529
2 changed files with 5 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.context.TraceScope;
import io.opentracing.Scope;
import io.opentracing.util.GlobalTracer;
import java.lang.reflect.Method;
@ -107,6 +108,9 @@ public final class HandlerAdapterInstrumentation extends Instrumenter.Default {
final String operationName = DECORATE.spanNameForClass(clazz) + "." + methodName;
final Scope scope = GlobalTracer.get().buildSpan(operationName).startActive(true);
if (scope instanceof TraceScope) {
((TraceScope) scope).setAsyncPropagation(true);
}
DECORATE.afterStart(scope);
return scope;
}

View File

@ -2,7 +2,7 @@ package datadog.trace.context;
import java.io.Closeable;
/** An object when can propagate a datadog trace across multiple threads. */
/** An object that can propagate a datadog trace across multiple threads. */
public interface TraceScope extends Closeable {
/**
* Prevent the trace attached to this TraceScope from reporting until the returned Continuation