-
Notifications
You must be signed in to change notification settings - Fork 40.3k
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
MeterRegistry not always processed by MeterRegistryPostProcessor #40913
Comments
Unfortunately, I don't think we can justify doing that without fully understanding the problem as this sort of change is likely to mask an underlying issue. It sounds like something is creating the Ideally, you'd share a sample that reproduces the problem. If that's not possible, please share the log output of your application when it's starting up. The default info level may be sufficient to point us in the right direction. Debug logging would be even better as it should identify the names of the beans that are being created and that are triggering the early creation of the |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue. |
sorry for not replying before. We identified the root cause of the issue in one of our internal libraries. A MeterRegistry was expected in constructor of one of our classes annotated with @configuration. @Configuration(proxyBeanMethods = false)
class MyConfiguration(private val meterRegistry: MeterRegistry) {
@Bean
fun bean1(): MyBean {
return MyBean(meterRegistry)
}
@Bean
fun bean2(): MyBean {
return MyBean(meterRegistry);
}
} I assume that the injection in constructor was causing the early instantiation of the MeterRegistry (before post processor). @Configuration(proxyBeanMethods = false)
class MyConfiguration {
@Bean
fun bean1(meterRegistry: MeterRegistry): MyBean {
return MyBean(meterRegistry)
}
@Bean
fun bean2(meterRegistry: MeterRegistry): MyBean {
return MyBean(meterRegistry);
}
} |
To support production of metrics in OTLP format by our microservices, we are considering using the following libraries:
org.springframework.boot:spring-boot-actuator-autoconfigure
io.micrometer:micrometer-registry-otlp
We are currently using Spring Boot 3.2.4.
In some microservices, we noticed that the bean
org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryPostProcessor
(created byorg.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration
) is created after the bean OtlpMeterRegistry (created byorg.springframework.boot.actuate.autoconfigure.metrics.export.otlp.OtlpMetricsExportAutoConfiguration
).As a result, post-processing done by MeterRegistryPostProcessor is not applied on this meter registry, namely:
management.metrics.enabled.*
)We only notice it on some internal projects that I can't share.
I was not able to create a simple reproducer project to reproduce it.
Since MeterRegistryPostProcessor is currently package-private, we can't force its creation early at application startup.
Could you consider making MeterRegistryPostProcessor public ?
Could you consider adding a MeterRegistryPostProcessor as argument of constructor of OtlpMetricsExportAutoConfiguration to ensure that it is always created before OtlpMeterRegistry ?
Same would be required for other MetricsExportAutoConfiguration classes to ensure that it works for other meter registries.
If you agree with one of the propositions below, I can contribute to the resolution of the issue.
The text was updated successfully, but these errors were encountered: