-
Notifications
You must be signed in to change notification settings - Fork 166
Description
Expected Behavior
All Meter binders, filters, customizers present in Spring context applied timely and correctly
Actual Behavior
After updating Temporal libs from 1.22.3 to 1.28.4 NonRootBeanPostProcessor, via Scope in MetricsScopeAutoConfiguration, caused MeterRegistry to be instantiated before MeterRegistryPostProcessor is added to bean factory's postprocessors and thus a lot of code relying on meter binders (like JvmMetricsAutoConfiguration) or Micrometer's globalRegistry containing all meter registries (which are added to it by said MeterRegistryPostProcessor) is unable to create Meters.
This happens because NonRootBeanPostProcessor is instantiated in the same loop as MeterRegistryPostProcessor and they're only added to bean factory later
Spring detects such situations and writes the following log message to make the user aware of them:
WARN 27112 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'prometheusMeterRegistry' of type [io.micrometer.prometheusmetrics.PrometheusMeterRegistry] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected/applied to a currently created BeanPostProcessor [nonRootBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies/advisors. If this bean does not have to be post-processed, declare it with ROLE_INFRASTRUCTURE.
So one or both dependencies (NonRootBeanPostProcessor on scope and scope on MeterRegistry) need to be made lazy
Steps to Reproduce the Problem
You can take the repro case from here: spring-projects/spring-boot#22926 (comment) - it's the same problem that occurred with a different set of libraries
Specifications
- Version: 1.28.4
- Platform: all