From 064f78c5d6a7bbba298957028130ba9df5b81103 Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Thu, 13 Jun 2024 11:40:18 +0200 Subject: [PATCH 1/4] Fix GraphQL v20 instrumentation to not break indy tests --- .../v20_0/GraphqlInstrumentationModule.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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..79e05974ec78 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 @@ -12,11 +12,15 @@ import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import java.util.Collections; import java.util.List; +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 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,13 @@ 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); + } } From f372119bae3d91d974b36c7cbb8f93f11bfb3e87 Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Thu, 13 Jun 2024 12:11:30 +0200 Subject: [PATCH 2/4] Disable indy for new finagle and reactor instrumentations --- .../v23_11/FinagleHttpInstrumentationModule.java | 6 ++++++ .../ContextPropagationOperator34InstrumentationModule.java | 6 ++++++ 2 files changed, 12 insertions(+) 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/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; + } } From b256e231e2a65200dd7c05123353534049ef25a9 Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Thu, 13 Jun 2024 12:45:29 +0200 Subject: [PATCH 3/4] spotless --- .../graphql/v20_0/GraphqlInstrumentationModule.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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 79e05974ec78..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,17 +10,17 @@ import com.google.auto.service.AutoService; import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; -import java.util.Collections; -import java.util.List; 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 implements - ExperimentalInstrumentationModule { +public class GraphqlInstrumentationModule extends InstrumentationModule + implements ExperimentalInstrumentationModule { public GraphqlInstrumentationModule() { super("graphql-java", "graphql-java-20.0"); @@ -42,7 +42,8 @@ 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") + injector + .proxyBuilder("io.opentelemetry.javaagent.instrumentation.graphql.v20_0.GraphqlSingletons") .inject(InjectionMode.CLASS_ONLY); } } From 15df3c23000d919b89f38dcedc51fa32d030af73 Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Thu, 13 Jun 2024 13:35:06 +0200 Subject: [PATCH 4/4] Disable indy for influx instrumentation --- .../influxdb/v2_4/InfluxDbInstrumentationModule.java | 6 ++++++ 1 file changed, 6 insertions(+) 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; + } }