Skip to content

Commit 2caff62

Browse files
authored
make azure-core indy-ready (#14681)
1 parent 7b00732 commit 2caff62

File tree

7 files changed

+35
-13
lines changed

7 files changed

+35
-13
lines changed

instrumentation/azure-core/azure-core-1.14/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/azurecore/v1_14/AzureHttpClientInstrumentation.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
1616
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
1717
import net.bytebuddy.asm.Advice;
18+
import net.bytebuddy.asm.Advice.AssignReturned;
1819
import net.bytebuddy.description.type.TypeDescription;
1920
import net.bytebuddy.matcher.ElementMatcher;
2021
import reactor.core.publisher.Mono;
@@ -39,9 +40,10 @@ public void transform(TypeTransformer transformer) {
3940
@SuppressWarnings("unused")
4041
public static class SuppressNestedClientAdvice {
4142

43+
@AssignReturned.ToReturned
4244
@Advice.OnMethodExit(suppress = Throwable.class)
43-
public static void methodExit(@Advice.Return(readOnly = false) Mono<HttpResponse> mono) {
44-
mono = new SuppressNestedClientMono<>(mono);
45+
public static Mono<HttpResponse> methodExit(@Advice.Return Mono<HttpResponse> mono) {
46+
return new SuppressNestedClientMono<>(mono);
4547
}
4648
}
4749
}

instrumentation/azure-core/azure-core-1.14/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/azurecore/v1_14/AzureSdkInstrumentationModule.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,9 @@ public void transform(TypeTransformer transformer) {
7777
// Nothing to instrument, no methods to match
7878
}
7979
}
80+
81+
@Override
82+
public boolean isIndyReady() {
83+
return true;
84+
}
8085
}

instrumentation/azure-core/azure-core-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/azurecore/v1_19/AzureHttpClientInstrumentation.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
1616
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
1717
import net.bytebuddy.asm.Advice;
18+
import net.bytebuddy.asm.Advice.AssignReturned;
1819
import net.bytebuddy.description.type.TypeDescription;
1920
import net.bytebuddy.matcher.ElementMatcher;
2021
import reactor.core.publisher.Mono;
@@ -39,9 +40,10 @@ public void transform(TypeTransformer transformer) {
3940
@SuppressWarnings("unused")
4041
public static class SuppressNestedClientAdvice {
4142

43+
@AssignReturned.ToReturned
4244
@Advice.OnMethodExit(suppress = Throwable.class)
43-
public static void methodExit(@Advice.Return(readOnly = false) Mono<HttpResponse> mono) {
44-
mono = new SuppressNestedClientMono<>(mono);
45+
public static Mono<HttpResponse> methodExit(@Advice.Return Mono<HttpResponse> mono) {
46+
return new SuppressNestedClientMono<>(mono);
4547
}
4648
}
4749
}

instrumentation/azure-core/azure-core-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/azurecore/v1_19/AzureSdkInstrumentationModule.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,9 @@ public void transform(TypeTransformer transformer) {
7777
// Nothing to instrument, no methods to match
7878
}
7979
}
80+
81+
@Override
82+
public boolean isIndyReady() {
83+
return true;
84+
}
8085
}

instrumentation/azure-core/azure-core-1.36/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/azurecore/v1_36/AzureHttpClientInstrumentation.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
import io.opentelemetry.context.Scope;
1919
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
2020
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
21+
import javax.annotation.Nullable;
2122
import net.bytebuddy.asm.Advice;
23+
import net.bytebuddy.asm.Advice.AssignReturned;
2224
import net.bytebuddy.description.type.TypeDescription;
2325
import net.bytebuddy.matcher.ElementMatcher;
2426
import reactor.core.publisher.Mono;
@@ -50,27 +52,26 @@ public void transform(TypeTransformer transformer) {
5052

5153
@SuppressWarnings("unused")
5254
public static class SuppressNestedClientMonoAdvice {
55+
@AssignReturned.ToReturned
5356
@Advice.OnMethodExit(suppress = Throwable.class)
54-
public static void asyncSendExit(
57+
public static Mono<HttpResponse> asyncSendExit(
5558
@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);
5861
}
5962
}
6063

6164
@SuppressWarnings("unused")
6265
public static class SuppressNestedClientSyncAdvice {
6366

67+
@Nullable
6468
@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);
6971
}
7072

7173
@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) {
7475
if (scope != null) {
7576
scope.close();
7677
}

instrumentation/azure-core/azure-core-1.36/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/azurecore/v1_36/AzureSdkInstrumentationModule.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,9 @@ public void transform(TypeTransformer transformer) {
7777
// Nothing to instrument, no methods to match
7878
}
7979
}
80+
81+
@Override
82+
public boolean isIndyReady() {
83+
return true;
84+
}
8085
}

instrumentation/azure-core/azure-core-1.36/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/azurecore/v1_36/SuppressNestedClientHelper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
import io.opentelemetry.context.Context;
1212
import io.opentelemetry.context.Scope;
1313
import io.opentelemetry.instrumentation.api.internal.SpanKey;
14+
import javax.annotation.Nullable;
1415
import reactor.core.CoreSubscriber;
1516
import reactor.core.publisher.Mono;
1617

1718
public class SuppressNestedClientHelper {
1819

20+
@Nullable
1921
public static Scope disallowNestedClientSpanSync(com.azure.core.util.Context azContext) {
2022
Context parentContext = currentContext();
2123
boolean hasAzureClientSpan = azContext.getData("client-method-call-flag").isPresent();

0 commit comments

Comments
 (0)