Skip to content
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

MeterRegistryPostProcessor not ran when MeterRegistry injected in cache configuration beans #29053

Closed
Nik95 opened this issue Dec 15, 2021 · 2 comments
Labels
status: duplicate A duplicate of another issue

Comments

@Nik95
Copy link

Nik95 commented Dec 15, 2021

I wanted to add some metrics provided by Lettuce for monitoring purpose of connections to Redis.
But when injecting MeterRegistry in our Configuration class, MeterRegistryProcessor is no longer called, hence MeterRegistry is not configured.

Similar issue has been reported here #18565, but only a fix for Spring Cloud Sleuth use case has been done.

I've built a minimal sample application to reproduce issue: https://github.com/Nik95/sample-spring-boot

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 15, 2021
@snicoll
Copy link
Member

snicoll commented Dec 15, 2021

Thanks for the sample.

Running it leads to the following:

2021-12-15 15:14:05.681  INFO 67962 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration' of type [org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-15 15:14:05.698  INFO 67962 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'management.metrics.export.simple-org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleProperties' of type [org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-15 15:14:05.701  INFO 67962 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'simpleConfig' of type [org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimplePropertiesConfigAdapter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-15 15:14:05.704  INFO 67962 --- [           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)
2021-12-15 15:14:05.705  INFO 67962 --- [           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)
2021-12-15 15:14:05.726  INFO 67962 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'simpleMeterRegistry' of type [io.micrometer.core.instrument.simple.SimpleMeterRegistry] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-15 15:14:05.728  INFO 67962 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'cacheConfiguration' of type [org.example.CacheConfiguration$$EnhancerBySpringCGLIB$$5d2571d3] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

This is due to early initialization of CachingConfigurer that was fixed today and will be available with the next release. I've updated your sample app to 2.6.2-SNAPSHOT and this went away.

A couple of remarks about the sample: there's no need to provide a version for Spring Data Redis or Lettuce, and using field autowiring on the MeterRegistry isn't great regardless as it forces the container to resolve that very early. A much better approach for this would be a customization using ClientResourcesBuilderCustomizer. That's actually what Spring Boot does out of the box.

@snicoll snicoll closed this as completed Dec 15, 2021
@snicoll snicoll added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 15, 2021
@Nik95
Copy link
Author

Nik95 commented Dec 15, 2021

Thanks @snicoll for the fix.

Regarding your remarks, it is just because I copy/paste code from our actual prod application that use an older Spring / Spring boot version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants