|
5 | 5 | import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named; |
6 | 6 | import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.namedOneOf; |
7 | 7 | import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan; |
8 | | -import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScope; |
| 8 | +import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan; |
| 9 | +import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.closeActive; |
9 | 10 | import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.noopSpan; |
10 | 11 | import static net.bytebuddy.matcher.ElementMatchers.isMethod; |
11 | 12 | import static net.bytebuddy.matcher.ElementMatchers.isPublic; |
|
14 | 15 | import com.google.auto.service.AutoService; |
15 | 16 | import datadog.trace.agent.tooling.Instrumenter; |
16 | 17 | import datadog.trace.agent.tooling.InstrumenterModule; |
17 | | -import datadog.trace.bootstrap.instrumentation.api.AgentScope; |
| 18 | +import datadog.trace.bootstrap.instrumentation.api.AgentSpan; |
| 19 | +import datadog.trace.bootstrap.instrumentation.api.AgentTracer; |
| 20 | +import datadog.trace.context.TraceScope; |
18 | 21 | import net.bytebuddy.asm.Advice; |
19 | 22 | import net.bytebuddy.description.type.TypeDescription; |
20 | 23 | import net.bytebuddy.matcher.ElementMatcher; |
@@ -69,27 +72,29 @@ public static class AwsHttpClientAdvice { |
69 | 72 | * stored in channel attributes. |
70 | 73 | */ |
71 | 74 | @Advice.OnMethodEnter(suppress = Throwable.class) |
72 | | - public static AgentScope methodEnter( |
| 75 | + public static TraceScope methodEnter( |
73 | 76 | @Advice.This final Object thiz, |
74 | 77 | @Advice.Argument(1) final RequestExecutionContext requestExecutionContext) { |
75 | | - final AgentScope scope = activeScope(); |
| 78 | + final AgentSpan activeSpan = activeSpan(); |
76 | 79 | // check name in case TracingExecutionInterceptor failed to activate the span |
77 | | - if (scope != null |
78 | | - && ((!scope.span().isValid()) |
| 80 | + if (activeSpan != null |
| 81 | + && ((!activeSpan.isValid()) |
79 | 82 | || AwsSdkClientDecorator.DECORATE |
80 | 83 | .spanName(requestExecutionContext.executionAttributes()) |
81 | | - .equals(scope.span().getSpanName()))) { |
| 84 | + .equals(activeSpan.getSpanName()))) { |
82 | 85 | if (thiz instanceof MakeAsyncHttpRequestStage) { |
83 | | - scope.close(); // close async legacy HTTP span to avoid Netty leak |
| 86 | + // close async legacy HTTP span to avoid Netty leak... |
| 87 | + closeActive(); // then drop-through and activate no-op span |
84 | 88 | } else { |
85 | | - return scope; // keep sync legacy HTTP span alive for duration of call |
| 89 | + // keep sync legacy HTTP span alive for duration of call |
| 90 | + return AgentTracer::closeActive; |
86 | 91 | } |
87 | 92 | } |
88 | 93 | return activateSpan(noopSpan()); |
89 | 94 | } |
90 | 95 |
|
91 | 96 | @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) |
92 | | - public static void methodExit(@Advice.Enter final AgentScope scope) { |
| 97 | + public static void methodExit(@Advice.Enter final TraceScope scope) { |
93 | 98 | scope.close(); |
94 | 99 | } |
95 | 100 |
|
|
0 commit comments