Closed wzy531a closed 1 year ago
Hey @wzy531a ,
I fixed your issue in https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/7447
But as a javaagent, is it reasonable to inject beans into user programs?
Theoretically, you don't have to do that, you could just inject bytecode into internal Spring classes. We find that approach rather fragile, and if possible we try to use the built-in mechanisms of the instrumented library (if there are any) to add the instrumentation code. In the case of spring web&webmvs, that means injecting a custom servlet Filter
just as if it was added by the app, and letting Spring handle the rest.
Describe the bug When the SpringWeb project uses Spring-Guice to implement ioc, there is a conflict with opentelemetry-javaagent. The opentelemetry-javaagent will make the SpringWeb termination.
Steps to reproduce You can run the demo with opentelemetry-javaagent.jar to reproduce this bug.
What did you expect to see?
What did you see instead?
What version are you using? jdk 1.8 spring-guice 2.0.2 springboot 2.7.6 otel-javaagent 1.20.2
Environment Linux
Additional context This problem is caused by Otel-Spring-Web-Instrument injecting beans into spring. If
@GuiceModule(excludeNames = {"bean"})
of OtelGuiceConfig.java in demo is changed to@GuiceModule(excludeNames = {"bean", "otelAutoDispatcherFilter" })
, you can skip this bean. But as a javaagent, is it reasonable to inject beans into user programs? At least Skywalking did not do so when SpringWeb detected.