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

Add counter name to exception message when negative value is detected #1090

Open
AntuanRokanten opened this issue Oct 4, 2024 · 1 comment

Comments

@AntuanRokanten
Copy link

Description:

I am using micrometer-registry-prometheus version 1.13.0 with Spring Boot 3.3.0, and sometimes I encounter the following exception when Prometheus scrapes metrics:

java.lang.IllegalArgumentException: -2.0: counters cannot have a negative value
at io.prometheus.metrics.model.snapshots.CounterSnapshot$CounterDataPointSnapshot.validate(CounterSnapshot.java:74)
at io.prometheus.metrics.model.snapshots.CounterSnapshot$CounterDataPointSnapshot.(CounterSnapshot.java:58)
at io.prometheus.metrics.model.snapshots.CounterSnapshot$CounterDataPointSnapshot.(CounterSnapshot.java:46)
at io.micrometer.prometheusmetrics.PrometheusMeterRegistry.lambda$newFunctionCounter$20(PrometheusMeterRegistry.java:372)
at io.micrometer.prometheusmetrics.MicrometerCollector.collect(MicrometerCollector.java:77)
at io.prometheus.metrics.model.registry.PrometheusRegistry.scrape(PrometheusRegistry.java:72)
at io.prometheus.metrics.model.registry.PrometheusRegistry.scrape(PrometheusRegistry.java:57)
at org.springframework.boot.actuate.metrics.export.prometheus.PrometheusScrapeEndpoint.scrape(PrometheusScrapeEndpoint.java:59)

The error message indicates that a counter has a negative value, but it does not specify which counter is causing the problem. This makes it difficult to identify the source of the issue in large applications with multiple counters.

Suggestion:

It would be helpful if the exception message included the name of the counter that is causing the problem. This additional information would significantly improve the ability to troubleshoot issues, especially in complex applications.

@zeitlinger
Copy link
Member

PR is welcome 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants