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
Bug(?) in prometheus.CounterVec #1429
Comments
I ran into the same issue in our production code and traced it back to |
Hello! Glad to meet someone with a similar problem. Try rewriting the variable into a new variable before passing it to the Prometheus function. I can't explain why, but it seems to be starting to work. I still haven’t been able to figure out the reasons why this doesn’t work( By the way, I couldn’t find in the source code where this map could change |
Hey @Nicik, unfortunately no luck with variable passing, still the same issue. I'll try to dig up more, it would be nice if we can get some clarity on why and where the previously added metric gets updated with new label value. |
@Nicik, you are using Fiber, in Fiber http parameters, body unsafe and mutable. Set |
Hello everyone! I am faced with the problem of re-registering metrics. I have seen the last occurrence of a similar problem in #242.
Link to the repository with the sample code: https://github.com/niciki/prom_bug/tree/main
OS: MacOS 14.1.1 M1 Pro,
Golang: 1.21
client_golang: 1.18.0
I am creating the following metric:
and I plan to count the access to the method with a different, small number of different ids.
There is a problem with the following requests at the same time:
and after them I try get metrics:
and I get an error of about the following type:
I register this metric once and therefore this error caught me by surprise. I tried to make test conclusions of the variable id transmitted by passing it to the function
sm.WithLabelValues(id).Add(1)
, thinking that I was having some kind of error, but no, everything was correct. This may be useful, but I was interested in digging into the prometheus source code and I noticed the following.I found that it looks like an array that stores hashes and label values is being changed:
it seems that the number that corresponds to its hash is changing, but I could not understand the possible reason for this behavior:
The text was updated successfully, but these errors were encountered: