Merge pull request #856 from DataDog/labbati/set-spring-controller-async

Make spring controller spans to handle async
This commit is contained in:
Luca Abbati 2019-05-24 18:47:35 +02:00 committed by GitHub
commit a3a98ceac8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 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;
}