Closed dquintela closed 4 years ago
Thanks for the report. This could be a duplicate of https://github.com/spring-projects/spring-boot/pull/21134, but it's hard to tell from the information provided thus far. Piecing things back together from a dependency tree is likely to be error-prone, particularly when parts of it appear to be proprietary. If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.
I was kinda sleepy last night to make a reproducer.. I'll make one today and I will provide it..
Here we go...
https://github.com/dquintela/spring-boot-22926-reproducer and https://github.com/dquintela/spring-boot-22926-reproducer/blob/master/notes.md
It seems to be related to a spring cloud issue - when spring cloud is included, it doesn't work - check notes and commits
Thanks for the sample. There are 9 info messages regarding beans not being eligible for post-processing:
2020-08-13 16:13:41.594 INFO 29531 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus.PrometheusMetricsExportAutoConfiguration' of type [org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus.PrometheusMetricsExportAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-08-13 16:13:41.605 INFO 29531 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'management.metrics.export.prometheus-org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus.PrometheusProperties' of type [org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus.PrometheusProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-08-13 16:13:41.610 INFO 29531 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'prometheusConfig' of type [org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus.PrometheusPropertiesConfigAdapter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-08-13 16:13:41.619 INFO 29531 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'collectorRegistry' of type [io.prometheus.client.CollectorRegistry] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-08-13 16:13:41.624 INFO 29531 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration' of type [org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-08-13 16:13:41.626 INFO 29531 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'micrometerClock' of type [io.micrometer.core.instrument.Clock$1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-08-13 16:13:41.643 INFO 29531 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'prometheusMeterRegistry' of type [io.micrometer.prometheus.PrometheusMeterRegistry] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-08-13 16:13:41.657 INFO 29531 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'metricsConfiguration' of type [org.example.springboot.issue22926.MetricsConfiguration$$EnhancerBySpringCGLIB$$cea27382] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-08-13 16:13:41.671 INFO 29531 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'metricsAdvisor' of type [org.example.springboot.issue22926.DummyMetricsAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
If I remove the Sleuth dependency, these info messages disappear and the JVM metrics are then present.
Sleuth makes extensive use of AOP. This, combined with your DummyMetricsAdvisor
, is the cause of the problem. By making your advisor depend on MeterRegistry
you're triggering initialization of all of the metrics infrastructure as soon as the bean post-processor that creates AOP proxies kicks. The AOP proxy creation needs to initialise your advisor to check if it wants to advise the beans being created. One way to avoid the problem is to add @Lazy
to the MeterRegistry
injection point:
public MetricsConfiguration(@Lazy MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
}
Exactly what I noticed just now, need to separate in my advisor to receive a bean name and resolve the MeterRegistry later on first use I guess.
The common solution to this PostProcessorIssues
Yeah, that's a good alternative to using @Lazy
. Another is to inject an ObjectProvider
and retrieve the bean from that on first-use.
https://github.com/spring-projects/spring-framework/issues/24092 is tracking making this sort of problem easier to diagnose. I don't think there's anything we can do to address this in Boot so I'll close this in favour of the Framework issue.
Just created a lazy proxy @ Lazy on metrics advisor - fixed
Using prometheus, ehcache.. with spring boot 2.3.2 The MeterRegistryPostProcessor seems to be instantiated after prometheusRegistry - it fails to register the system metrics registered on JvmMetricsAutoConfiguration for example. This behaviour seems to be related to a new issue - PropertiesMeterFilter is instantiated but not applied to prometheusRegistry so the other metrics that get registered - don't get to be affected by common tags - the workaround for that is instantiating prometheusRegistry by myself and register commonTags there - the workaround for the MeterRegistryPostProcessor could be similar.
This is what is exported on prometheus endpoint
Application deps by dependency:tree for reference