-
Notifications
You must be signed in to change notification settings - Fork 182
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
Implements a set() method for Counters #303
Conversation
Thanks! I'm mostly fine with the PR. However I'm curious that looks like this scenario should use a Gauge instead? |
Hi, One reason is consistency. Having it as a gauge seems also seems to be an issue for the |
@jedisct1 How about increasing two counters simultaneously in this case? e.g. increase client_queries when increasing client_queries_udp, and increase client_queries when increasing client_queries_tcp. Notice that the official prometheus client library does not support setting the value for a counter as well and I'm very worried about encouraging abuse after the change. |
setting the counter breaks the rule of Prometheus, see https://prometheus.io/docs/concepts/metric_types/#counter So I think we still need to not allow this. |
Incrementing both counters is something to think about every time, and is bug-prone. The proposed code ensures that the set operation can only increase a counter (the current |
@jedisct1 @jedisct1 @siddontang How about put these unrecommended methods behind a feature gate (like |
This use case and the reset PR that added a
That's probably a good workaround until ConstMetrics appear. |
I am as well not in favor of adding a Instead of introducing a feature gate I think people trying to reexpose counters from an underlying system (e.g. the OS) should implement custom collectors. @jedisct1 I am closing this as I feel the discussion has stalled. Feel free to either reopen this pull request or post another if you would like to discuss this further. |
Being able to set a counter is useful when a counter is set at scrape time, for example to the sum of other counters.
Prometheus doesn't have any issues with Counters getting reset.