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
Metrics static methods use a different registry than the injected MeterRegistry #2633
Comments
This sounds like a new bug. Out of curiosity, do you see any messages about |
Yes, several, currently these are the relevant beans mentioned which are not eligible:
|
That is the smoking gun. By You might have a dependency or code that is instantiating the Prometheus registry very early. See spring-projects/spring-framework#24092 for an overview (and note the linked Micrometer issues to see some more details) Unfortunately this sounds like a Spring Boot issue. |
Sounds like spring-projects/spring-boot#26630, which is fixed in the upcoming Spring Boot 2.5.1 release, scheduled for June 10. I would suggest trying your application on Spring Boot 2.5.1 snapshots to ensure the issue is fixed for you. Under the assumption that is the cause, I'll close this as a duplicate of that issue. If that turns out to not be the case, we can reopen and investigate further. |
I can confirm the workaround mentioned in spring-projects/spring-boot#26630 (which originates from https://stackoverflow.com/questions/57607445/spring-actuator-jvm-metrics-not-showing-when-globalmethodsecurity-is-enabled/57908577#57908577) fixes my issue. So until 2.5.1 is released, I have implemented this workaround. This means there is nothing more to be done in this issue, so I will close it and I hope that whoever finds this issue also finds the mentioned workaround. |
Were you able to try snapshots without a workaround? It would be good to check that everything works as expected with the fix and no workarounds. |
I tested this with Spring Boot 2.5.1 and sadly, the problem still exists. Using the When I re-added the workaround mentioned in the related issue:
...it worked again. |
Same issue also with Spring Boot 2.5.3 |
Can you provide a minimal sample project for us to run that reproduces the issue? |
Closing until we can get a minimal sample project that reproduces the issue for us to investigate further. |
I don't know whether this belongs on the Spring Boot side, but basically since version 1.7.0 of Micrometer and 2.5.0 of Spring Boot, all of my custom metrics had disappeared.
After some research, it seems like
Metrics.counter("test").increment()
adds the counter to the global registry which is aCompositeMeterRegistry
. This counter does not get displayed at endpoint/actuator/metrics
nor/actuator/prometheus
.When I use an injected
MeterRegistry
, I get a registry of typePrometheusMeterRegistry
(I assume because of my micrometer-registry-prometheus dependency). If I register my counter with this registry, it is both shown in the metrics and prometheus endpoint.Is there some configuration which I'm missing or is this a (known) bug?
The text was updated successfully, but these errors were encountered: