Skip to content

Commit

Permalink
Fix testIndy on main (#11582)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKunz authored Jun 13, 2024
1 parent 55e723e commit 9f11c4a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public List<TypeInstrumentation> 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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -32,4 +36,14 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
public List<TypeInstrumentation> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ public InfluxDbInstrumentationModule() {
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new InfluxDbImplInstrumentation());
}

@Override
public boolean isIndyModule() {
// Uses multiple Advice.Locals and argument assignment
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new ContextPropagationOperator34Instrumentation());
}

@Override
public boolean isIndyModule() {
// Requires Otel-API bride
return false;
}
}

0 comments on commit 9f11c4a

Please sign in to comment.