Closed hatzlj closed 1 year ago
I just encountered that in one of our projects and had no time to reproduce it on a minimal project yet. However I just wanted to document the issue here in case someone stumbles upon it, since it took me quite some time to track down why my metrics are missing.
I'm not a spring auto-configuration specialist but I guess that this might be fixable by some spring
@AutoConfiguration(after=...)
or @Order
magic?
Hello @hatzlj, thanks for reporting the issue! We have not encountered this in our own applications, hence why it's not picked up. Reading some more about this, we might have implemented the wrong BeanPostProcessor
method, so I will correct that. I will also make the BeanPostProcessor
implement PriorityOrdered
, so it's initialized after.
If I release a snapshot, would you be willing to test it out?
Apparently, PriorityOrdered
post processors are always before non-prioritized ones. Since MeterRegistryPostProcessor
doesn't implement it, it will only make matters worse.
As suggested, I will make the autoconfiguration initialize after the MetricsAutoConfiguration
of micrometer.
I have it reproduced, and the fix with autoconfigure-ordering does not work, unfortunately. The issue occurs, for me, when running in a docker container. When running from IDEA, it totally works
I found out why; it's not the autoconfigure ordering causing this; it's the required Configuration
parameter to the method, causing initialization of the metrics before this point. I will look into a solution for this, but this might take some time
Hey @Morlack! Thanks for having a look on this (and fixing it) so quick. Yes, also here it only happens within a docker container. I would be curious if you found out why it works in the IDE but not within a container.
No worries, an issue of this magnitude should be fixed fast. To be honest, I have no idea why it differs between IntelliJ and Docker (or perhaps running the Spring Boot jar). It might just be the classpath scanning between a dynamic classpath and the uberjar works similarly, but just differently enough to botch the ordering. In order to keep my sanity, I will just keep that as a fact! ;)
The fix is available: https://repo1.maven.org/maven2/io/axoniq/inspector/inspector-axon/0.1.5/
Basic information
Steps to reproduce
Expected behaviour
Actual behaviour
spanFactoryInspectorPostProcessor
bean configured inAxonInspectorAutoConfiguration
triggers early initialization of thePrometheusMeterRegistry
which leads to certain MeterBinders not being picked up by theMeterRegistryPostProcessor
. When debugging the initialization of the application context and breakpointing on initialization of thePrometheusMeterRegistry
i can see the following order of post processors inorg.springframework.context.support.PostProcessorRegistrationDelegate#registerBeanPostProcessors(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, org.springframework.context.support.AbstractApplicationContext)
:whereas as far as I understand https://github.com/micrometer-metrics/micrometer/issues/513#issuecomment-378755211 the
PrometheusMeterRegistry
should only be initialized after the meterRegistryPostProcessor.