Fix class file load error when using spring-guice together with sprin… (#7447)
…g-web instrumentation Fixes https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/7428
This commit is contained in:
parent
70df351c09
commit
8c64a9e6e1
|
@ -32,7 +32,7 @@ public class SpringBootActuatorInstrumentationModule extends InstrumentationModu
|
|||
public void registerHelperResources(HelperResourceBuilder helperResourceBuilder) {
|
||||
// autoconfigure classes are loaded as resources using ClassPathResource
|
||||
// this line will make OpenTelemetryMeterRegistryAutoConfiguration available to all
|
||||
// classloaders, so that the bean class loader (different than the instrumented class loader)
|
||||
// classloaders, so that the bean class loader (different from the instrumented class loader)
|
||||
// can load it
|
||||
helperResourceBuilder.registerForAllClassLoaders(
|
||||
"io/opentelemetry/javaagent/instrumentation/spring/actuator/OpenTelemetryMeterRegistryAutoConfiguration.class");
|
||||
|
|
|
@ -10,6 +10,7 @@ import static java.util.Collections.singletonList;
|
|||
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 java.util.List;
|
||||
|
@ -29,6 +30,16 @@ public class SpringWebInstrumentationModule extends InstrumentationModule {
|
|||
.and(not(hasClassesNamed("org.springframework.web.ErrorResponse")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHelperResources(HelperResourceBuilder helperResourceBuilder) {
|
||||
// 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 List<TypeInstrumentation> typeInstrumentations() {
|
||||
return singletonList(new WebApplicationContextInstrumentation());
|
||||
|
|
|
@ -9,6 +9,7 @@ import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.
|
|||
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 java.util.List;
|
||||
|
@ -27,6 +28,16 @@ public class SpringWebInstrumentationModule extends InstrumentationModule {
|
|||
return hasClassesNamed("org.springframework.web.ErrorResponse");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHelperResources(HelperResourceBuilder helperResourceBuilder) {
|
||||
// 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 List<TypeInstrumentation> typeInstrumentations() {
|
||||
return singletonList(new WebApplicationContextInstrumentation());
|
||||
|
|
Loading…
Reference in New Issue