make azure-core indy-ready (#14681)
This commit is contained in:
		
							parent
							
								
									7b00732fa8
								
							
						
					
					
						commit
						2caff625dd
					
				|  | @ -15,6 +15,7 @@ import com.azure.core.http.HttpResponse; | |||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||||
| import net.bytebuddy.asm.Advice; | ||||
| import net.bytebuddy.asm.Advice.AssignReturned; | ||||
| import net.bytebuddy.description.type.TypeDescription; | ||||
| import net.bytebuddy.matcher.ElementMatcher; | ||||
| import reactor.core.publisher.Mono; | ||||
|  | @ -39,9 +40,10 @@ public class AzureHttpClientInstrumentation implements TypeInstrumentation { | |||
|   @SuppressWarnings("unused") | ||||
|   public static class SuppressNestedClientAdvice { | ||||
| 
 | ||||
|     @AssignReturned.ToReturned | ||||
|     @Advice.OnMethodExit(suppress = Throwable.class) | ||||
|     public static void methodExit(@Advice.Return(readOnly = false) Mono<HttpResponse> mono) { | ||||
|       mono = new SuppressNestedClientMono<>(mono); | ||||
|     public static Mono<HttpResponse> methodExit(@Advice.Return Mono<HttpResponse> mono) { | ||||
|       return new SuppressNestedClientMono<>(mono); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -77,4 +77,9 @@ public class AzureSdkInstrumentationModule extends InstrumentationModule | |||
|       // Nothing to instrument, no methods to match | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   @Override | ||||
|   public boolean isIndyReady() { | ||||
|     return true; | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -15,6 +15,7 @@ import com.azure.core.http.HttpResponse; | |||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||||
| import net.bytebuddy.asm.Advice; | ||||
| import net.bytebuddy.asm.Advice.AssignReturned; | ||||
| import net.bytebuddy.description.type.TypeDescription; | ||||
| import net.bytebuddy.matcher.ElementMatcher; | ||||
| import reactor.core.publisher.Mono; | ||||
|  | @ -39,9 +40,10 @@ public class AzureHttpClientInstrumentation implements TypeInstrumentation { | |||
|   @SuppressWarnings("unused") | ||||
|   public static class SuppressNestedClientAdvice { | ||||
| 
 | ||||
|     @AssignReturned.ToReturned | ||||
|     @Advice.OnMethodExit(suppress = Throwable.class) | ||||
|     public static void methodExit(@Advice.Return(readOnly = false) Mono<HttpResponse> mono) { | ||||
|       mono = new SuppressNestedClientMono<>(mono); | ||||
|     public static Mono<HttpResponse> methodExit(@Advice.Return Mono<HttpResponse> mono) { | ||||
|       return new SuppressNestedClientMono<>(mono); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -77,4 +77,9 @@ public class AzureSdkInstrumentationModule extends InstrumentationModule | |||
|       // Nothing to instrument, no methods to match | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   @Override | ||||
|   public boolean isIndyReady() { | ||||
|     return true; | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -18,7 +18,9 @@ import com.azure.core.http.HttpResponse; | |||
| import io.opentelemetry.context.Scope; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||||
| import javax.annotation.Nullable; | ||||
| import net.bytebuddy.asm.Advice; | ||||
| import net.bytebuddy.asm.Advice.AssignReturned; | ||||
| import net.bytebuddy.description.type.TypeDescription; | ||||
| import net.bytebuddy.matcher.ElementMatcher; | ||||
| import reactor.core.publisher.Mono; | ||||
|  | @ -50,27 +52,26 @@ public class AzureHttpClientInstrumentation implements TypeInstrumentation { | |||
| 
 | ||||
|   @SuppressWarnings("unused") | ||||
|   public static class SuppressNestedClientMonoAdvice { | ||||
|     @AssignReturned.ToReturned | ||||
|     @Advice.OnMethodExit(suppress = Throwable.class) | ||||
|     public static void asyncSendExit( | ||||
|     public static Mono<HttpResponse> asyncSendExit( | ||||
|         @Advice.Argument(1) com.azure.core.util.Context azContext, | ||||
|         @Advice.Return(readOnly = false) Mono<HttpResponse> mono) { | ||||
|       mono = disallowNestedClientSpanMono(mono, azContext); | ||||
|         @Advice.Return Mono<HttpResponse> mono) { | ||||
|       return disallowNestedClientSpanMono(mono, azContext); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   @SuppressWarnings("unused") | ||||
|   public static class SuppressNestedClientSyncAdvice { | ||||
| 
 | ||||
|     @Nullable | ||||
|     @Advice.OnMethodEnter(suppress = Throwable.class) | ||||
|     public static void syncSendEnter( | ||||
|         @Advice.Argument(1) com.azure.core.util.Context azContext, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       scope = disallowNestedClientSpanSync(azContext); | ||||
|     public static Scope syncSendEnter(@Advice.Argument(1) com.azure.core.util.Context azContext) { | ||||
|       return disallowNestedClientSpanSync(azContext); | ||||
|     } | ||||
| 
 | ||||
|     @Advice.OnMethodExit(suppress = Throwable.class) | ||||
|     public static void syncSendExit( | ||||
|         @Advice.Return HttpResponse response, @Advice.Local("otelScope") Scope scope) { | ||||
|     public static void syncSendExit(@Advice.Enter @Nullable Scope scope) { | ||||
|       if (scope != null) { | ||||
|         scope.close(); | ||||
|       } | ||||
|  |  | |||
|  | @ -77,4 +77,9 @@ public class AzureSdkInstrumentationModule extends InstrumentationModule | |||
|       // Nothing to instrument, no methods to match | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   @Override | ||||
|   public boolean isIndyReady() { | ||||
|     return true; | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -11,11 +11,13 @@ import io.opentelemetry.api.trace.Span; | |||
| import io.opentelemetry.context.Context; | ||||
| import io.opentelemetry.context.Scope; | ||||
| import io.opentelemetry.instrumentation.api.internal.SpanKey; | ||||
| import javax.annotation.Nullable; | ||||
| import reactor.core.CoreSubscriber; | ||||
| import reactor.core.publisher.Mono; | ||||
| 
 | ||||
| public class SuppressNestedClientHelper { | ||||
| 
 | ||||
|   @Nullable | ||||
|   public static Scope disallowNestedClientSpanSync(com.azure.core.util.Context azContext) { | ||||
|     Context parentContext = currentContext(); | ||||
|     boolean hasAzureClientSpan = azContext.getData("client-method-call-flag").isPresent(); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue