Skip to content

Commit

Permalink
commit wip for investigation
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainJuge committed Aug 29, 2024
1 parent 278edf8 commit ad7440f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
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 io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import java.util.List;

@AutoService(InstrumentationModule.class)
public class ReflectionInstrumentationModule extends InstrumentationModule {
public class ReflectionInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {
public ReflectionInstrumentationModule() {
super("internal-reflection");
}
Expand All @@ -29,4 +33,17 @@ public boolean defaultEnabled(ConfigProperties config) {
public List<TypeInstrumentation> typeInstrumentations() {
return asList(new ClassInstrumentation(), new ReflectionInstrumentation());
}

@Override
public String getModuleGroup() {
return "internal-reflection";
}

@Override
public void injectClasses(ClassInjector injector) {
injector
.proxyBuilder(
"io.opentelemetry.javaagent.instrumentation.internal.reflection.ReflectionHelper")
.inject(InjectionMode.CLASS_ONLY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,16 @@ public static InstrumentationModuleClassLoader getInstrumentationClassLoader(

String groupName = getModuleGroup(module);

// this is a hack attempt to make it work
if (instrumentedClassLoader != null && instrumentedClassLoader.getClass().getName()
.startsWith("io.opentelemetry.javaagent.tooling.HelperInjector$1")) {
instrumentedClassLoader = null;
}

Map<String, InstrumentationModuleClassLoader> loadersByGroupName =
instrumentationClassLoaders.get(instrumentedClassLoader);


if (loadersByGroupName == null) {
throw new IllegalArgumentException(
module
Expand Down

0 comments on commit ad7440f

Please sign in to comment.