|
18 | 18 | import io.opentelemetry.context.Scope; |
19 | 19 | import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; |
20 | 20 | import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; |
| 21 | +import javax.annotation.Nullable; |
21 | 22 | import net.bytebuddy.asm.Advice; |
| 23 | +import net.bytebuddy.asm.Advice.AssignReturned; |
22 | 24 | import net.bytebuddy.description.type.TypeDescription; |
23 | 25 | import net.bytebuddy.matcher.ElementMatcher; |
24 | 26 | import reactor.core.publisher.Mono; |
@@ -50,27 +52,26 @@ public void transform(TypeTransformer transformer) { |
50 | 52 |
|
51 | 53 | @SuppressWarnings("unused") |
52 | 54 | public static class SuppressNestedClientMonoAdvice { |
| 55 | + @AssignReturned.ToReturned |
53 | 56 | @Advice.OnMethodExit(suppress = Throwable.class) |
54 | | - public static void asyncSendExit( |
| 57 | + public static Mono<HttpResponse> asyncSendExit( |
55 | 58 | @Advice.Argument(1) com.azure.core.util.Context azContext, |
56 | | - @Advice.Return(readOnly = false) Mono<HttpResponse> mono) { |
57 | | - mono = disallowNestedClientSpanMono(mono, azContext); |
| 59 | + @Advice.Return Mono<HttpResponse> mono) { |
| 60 | + return disallowNestedClientSpanMono(mono, azContext); |
58 | 61 | } |
59 | 62 | } |
60 | 63 |
|
61 | 64 | @SuppressWarnings("unused") |
62 | 65 | public static class SuppressNestedClientSyncAdvice { |
63 | 66 |
|
| 67 | + @Nullable |
64 | 68 | @Advice.OnMethodEnter(suppress = Throwable.class) |
65 | | - public static void syncSendEnter( |
66 | | - @Advice.Argument(1) com.azure.core.util.Context azContext, |
67 | | - @Advice.Local("otelScope") Scope scope) { |
68 | | - scope = disallowNestedClientSpanSync(azContext); |
| 69 | + public static Scope syncSendEnter(@Advice.Argument(1) com.azure.core.util.Context azContext) { |
| 70 | + return disallowNestedClientSpanSync(azContext); |
69 | 71 | } |
70 | 72 |
|
71 | 73 | @Advice.OnMethodExit(suppress = Throwable.class) |
72 | | - public static void syncSendExit( |
73 | | - @Advice.Return HttpResponse response, @Advice.Local("otelScope") Scope scope) { |
| 74 | + public static void syncSendExit(@Advice.Enter @Nullable Scope scope) { |
74 | 75 | if (scope != null) { |
75 | 76 | scope.close(); |
76 | 77 | } |
|
0 commit comments