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 "increment to" to counters #863

Open
Hoffs opened this issue Sep 13, 2023 · 0 comments
Open

Add "increment to" to counters #863

Hoffs opened this issue Sep 13, 2023 · 0 comments

Comments

@Hoffs
Copy link

Hoffs commented Sep 13, 2023

Similar to #554 I feel like it is pretty common and legitimate use-case when trying to expose external system metrics using prometheus. For example, there is a autoanalyze_count FROM pg_stat_user_tables stat which is pretty closely mapped to prometheus counter (name gives it away). The problem is that there is no easy safe way to accomplish correct increment. The "obvious" solution is to retrieve current counter value and increment the difference. But this has obvious race condition issues, where anything can happen between value is read and increment is added, where the end result becomes out of sync. In such case, what really is needed is "increment to" method.
prometheus-net library provides exactly that: https://github.com/prometheus-net/prometheus-net/blob/master/Prometheus/Counter.cs#L55

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

1 participant