Skip to content

Commit

Permalink
keep registerHelperResources for inlined
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainJuge committed Nov 27, 2024
1 parent 1427f9f commit a5806c6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static net.bytebuddy.matcher.ElementMatchers.not;

import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.HelperResourceBuilder;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
Expand All @@ -31,6 +32,21 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
.and(not(hasClassesNamed("org.springframework.web.ErrorResponse")));
}

@Override
public void registerHelperResources(HelperResourceBuilder helperResourceBuilder) {
if (!isIndyModule()) {
// make the filter class file loadable by ClassPathResource - in some cases (e.g.
// spring-guice,
// see https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/7428)
// Spring
// might want to read the class file metadata; this line will make the filter class file
// visible
// to the bean class loader
helperResourceBuilder.register(
"org/springframework/web/servlet/v3_1/OpenTelemetryHandlerMappingFilter.class");
}
}

@Override
public String getModuleGroup() {
// depends on OpenTelemetryHandlerMappingFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static java.util.Collections.singletonList;

import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.HelperResourceBuilder;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
Expand All @@ -29,6 +30,21 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
return hasClassesNamed("org.springframework.web.ErrorResponse");
}

@Override
public void registerHelperResources(HelperResourceBuilder helperResourceBuilder) {
if (!isIndyModule()) {
// make the filter class file loadable by ClassPathResource - in some cases (e.g.
// spring-guice,
// see https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/7428)
// Spring
// might want to read the class file metadata; this line will make the filter class file
// visible
// to the bean class loader
helperResourceBuilder.register(
"org/springframework/web/servlet/v6_0/OpenTelemetryHandlerMappingFilter.class");
}
}

@Override
public String getModuleGroup() {
// depends on OpenTelemetryHandlerMappingFilter
Expand Down

0 comments on commit a5806c6

Please sign in to comment.