From 9f11c4a36aab466f73bd22a5d147409105bff13c Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Thu, 13 Jun 2024 17:19:28 +0200 Subject: [PATCH] Fix testIndy on main (#11582) --- .../v23_11/FinagleHttpInstrumentationModule.java | 6 ++++++ .../v20_0/GraphqlInstrumentationModule.java | 16 +++++++++++++++- .../v2_4/InfluxDbInstrumentationModule.java | 6 ++++++ ...opagationOperator34InstrumentationModule.java | 6 ++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/instrumentation/finagle-http-23.11/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/finaglehttp/v23_11/FinagleHttpInstrumentationModule.java b/instrumentation/finagle-http-23.11/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/finaglehttp/v23_11/FinagleHttpInstrumentationModule.java index d15901c78535..ab8f9c9c9919 100644 --- a/instrumentation/finagle-http-23.11/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/finaglehttp/v23_11/FinagleHttpInstrumentationModule.java +++ b/instrumentation/finagle-http-23.11/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/finaglehttp/v23_11/FinagleHttpInstrumentationModule.java @@ -26,6 +26,12 @@ public List typeInstrumentations() { new H2StreamChannelInitInstrumentation()); } + @Override + public boolean isIndyModule() { + // injects helpers to access package-private members + return false; + } + @Override public boolean isHelperClass(String className) { return className.equals("com.twitter.finagle.ChannelTransportHelpers") diff --git a/instrumentation/graphql-java/graphql-java-20.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/graphql/v20_0/GraphqlInstrumentationModule.java b/instrumentation/graphql-java/graphql-java-20.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/graphql/v20_0/GraphqlInstrumentationModule.java index 160a03e89811..63d41ac3c5c9 100644 --- a/instrumentation/graphql-java/graphql-java-20.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/graphql/v20_0/GraphqlInstrumentationModule.java +++ b/instrumentation/graphql-java/graphql-java-20.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/graphql/v20_0/GraphqlInstrumentationModule.java @@ -10,13 +10,17 @@ import com.google.auto.service.AutoService; import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule; +import io.opentelemetry.javaagent.extension.instrumentation.internal.injection.ClassInjector; +import io.opentelemetry.javaagent.extension.instrumentation.internal.injection.InjectionMode; import java.util.Collections; import java.util.List; import net.bytebuddy.matcher.ElementMatcher; @SuppressWarnings("unused") @AutoService(InstrumentationModule.class) -public class GraphqlInstrumentationModule extends InstrumentationModule { +public class GraphqlInstrumentationModule extends InstrumentationModule + implements ExperimentalInstrumentationModule { public GraphqlInstrumentationModule() { super("graphql-java", "graphql-java-20.0"); @@ -32,4 +36,14 @@ public ElementMatcher.Junction classLoaderMatcher() { public List typeInstrumentations() { return Collections.singletonList(new GraphqlInstrumentation()); } + + @Override + public void injectClasses(ClassInjector injector) { + // we do not use ByteBuddy Advice dispatching in this instrumentation + // Instead, we manually call GraphqlSingletons via ASM + // Easiest solution to work with indy is to inject an indy-proxy to be invoked + injector + .proxyBuilder("io.opentelemetry.javaagent.instrumentation.graphql.v20_0.GraphqlSingletons") + .inject(InjectionMode.CLASS_ONLY); + } } diff --git a/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbInstrumentationModule.java b/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbInstrumentationModule.java index 3aba153fc408..3b95cc8b1c29 100644 --- a/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbInstrumentationModule.java +++ b/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbInstrumentationModule.java @@ -23,4 +23,10 @@ public InfluxDbInstrumentationModule() { public List typeInstrumentations() { return singletonList(new InfluxDbImplInstrumentation()); } + + @Override + public boolean isIndyModule() { + // Uses multiple Advice.Locals and argument assignment + return false; + } } diff --git a/instrumentation/reactor/reactor-3.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactor/v3_4/operator/ContextPropagationOperator34InstrumentationModule.java b/instrumentation/reactor/reactor-3.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactor/v3_4/operator/ContextPropagationOperator34InstrumentationModule.java index cb9d6addf50b..d783638f035d 100644 --- a/instrumentation/reactor/reactor-3.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactor/v3_4/operator/ContextPropagationOperator34InstrumentationModule.java +++ b/instrumentation/reactor/reactor-3.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactor/v3_4/operator/ContextPropagationOperator34InstrumentationModule.java @@ -31,4 +31,10 @@ public ElementMatcher.Junction classLoaderMatcher() { public List typeInstrumentations() { return singletonList(new ContextPropagationOperator34Instrumentation()); } + + @Override + public boolean isIndyModule() { + // Requires Otel-API bride + return false; + } }