-
Notifications
You must be signed in to change notification settings - Fork 828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception when using Spring Cloud Stream #7220
Comments
You could work around this by calling |
This works well, thanks |
I suppose we could fix it that way, but...
I think this issue might manifest even if OTel metrics API is used, even without spring - just loading an application class from within the callback function will probably blow up. |
Related to #7220 Unfortunately it doesn't fix the aforementioned issue; while the CL used is no longer the agent classloader, gauge collection still throws that error. Still, I think this is a good change that removes one source of agent's CL leaking into application runtime.
Describe the bug
When an application uses spring cloud stream and spring aspect, there will be an error when collect metrics.
Steps to reproduce
-javaagent:D:\DevelopSoftware\OpenTelemetry-agent\opentelemetry-javaagent.jar
-Dotel.traces.exporter=logging
-Dotel.metrics.exporter=logging
-Dotel.logs.exporter=logging
What did you expect to see?
No exception throw.
What version are you using?
Version 1.19.2
Environment
Compiler: Eclipse Temurin 1.8.0_302
OS: windows 10 21H1 64bit
Additional context
Anyway I think this problem is not caused by anyone, including spring and opentelemetry. It's just a coincidence.
I will try to analyze the it here.
The error is reported at
org.springframework.integration.config.IntegrationManagementConfigurer#registerComponentGauges
, As shown hereThis part of the logic is lazy loading, only when called will get and initialization of type
org.springframework.messaging.MessageHandler
. Here will get three beanName, The error is raised byluna-taskcore-exchange.taskcore.errors.handler
.When the
luna-taskcore-exchange.taskcore.errors.handler
bean is initializing, it's going to be processed by a BeanPostProcessor namedorg.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator
.The
AnnotationAwareAspectJAutoProxyCreator
will try all the aspects inorg.springframework.aop.support.AopUtils#findAdvisorsThatCanApply
method if it is suitable for the handler bean.On the other hand, when spring try to load my
com.example.demo.aspect.ExceptionAspect
, first it will process the aspectj expression byorg.springframework.aop.aspectj.AspectJExpressionPointcut#obtainPointcutExpression
.Here, it will use the current thread's classloader to process the aspectj expression and this is AgentClassloader now.So when load my expressionexecution(* com.example.demo.controller.CommonController.*(..))
, spring will raise an error as AgentClassloader don't know what CommonController is.The temporary solution is to load these bean in spring EventListener before the agent effect, but it's hard to know all the bean need to be early loaded.
And as #7037 say, the agent actualy can't load the application class.
So there is any other solution to solve this problem?
The text was updated successfully, but these errors were encountered: