Make trace annotation instrumentation async propagating

This commit is contained in:
Laplie Anderson 2019-10-07 10:15:17 +02:00
parent 654e09ee7f
commit 5719a783ad
1 changed files with 8 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import static datadog.trace.instrumentation.trace_annotation.TraceDecorator.DECO
import datadog.trace.api.DDTags;
import datadog.trace.api.Trace;
import datadog.trace.context.TraceScope;
import io.opentracing.Scope;
import io.opentracing.Tracer;
import io.opentracing.util.GlobalTracer;
@ -29,7 +30,13 @@ public class TraceAdvice {
}
spanBuilder = spanBuilder.withTag(DDTags.RESOURCE_NAME, resourceName);
return DECORATE.afterStart(spanBuilder.startActive(true));
final Scope scope = DECORATE.afterStart(spanBuilder.startActive(true));
if (scope instanceof TraceScope) {
((TraceScope) scope).setAsyncPropagation(true);
}
return scope;
}
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)