prometheus / prometheus/client_js
Counter reset that sets every value to zero
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 3.5k
- Forks
- 429
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 22
Description
I have a counter metric with a single label. It is initialized to zero for all possible values of the label, as is a best practice for counter metrics. This happens immediately after the metric is defined.
In my unit testing framework, I reset all metrics after each test, to make it easy to test the metrics themselves. However, this erases my initialization of everything to zero. That means that if I try to check that the value of my metric at a label is zero, it fails, because the metric actually has no value at that label.
It would be nice to have a version of reset() which sets counter metrics to zero. I guess it could be called "zeroOut", or something like that, and then there would be a "zeroOutMetrics" like "resetMetrics".
I suppose this function should also work on other metric types, for consistency.
I would be happy to open a pull request if you believe it is a good idea.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing reset() and resetMetrics() implementations and the tests covering metric reset behavior. Clarify the API and semantics for counters and other metric types; done should preserve initialized label values at zero after the new reset operation, with tests covering the supported metrics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100