-
Notifications
You must be signed in to change notification settings - Fork 41.2k
MeterRegistry not configured with Advisor bean that depends on it #19148
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
Comments
Thanks for the sample. There are a number of info messages logged which show that there's a problem with the dependency relationships between the beans in your app:
This is happening because you have injected You can avoid the problem by making the injected @Bean
public Advisor someAdvisor(@Lazy MeterRegistry meterRegistry) {
//…
} |
Thanks for looking into it. Should this be documented somewhere? |
The problem is broader than Spring Boot and its auto-configuration of There's a large section about AOP with a sub-section dedicated to understanding AOP's use of proxies. It's the use of proxies for AOP and a bean post-processor to create them that means that care must be taken when injecting dependencies into a bean that's an aspect or advisor. An update to this section of the documentation may make sense. I've opened spring-projects/spring-framework#24092. |
Awesome, thank you! |
Spring Boot 2.2.1.RELEASE
We use a Spring AOP
Advisor
bean inside a library to publish execution times of certain methods. This used to work fine with Spring Boot 1.4.2. Debugging showed that theAdvisor
bean (and with it theMeterRegistry
) is created before theMeterRegistryPostProcessor
so that theMeterRegistry
is not configured.Sample project: https://github.com/biergit/playground
The text was updated successfully, but these errors were encountered: