prometheus / prometheus/client_js

Counter reset that sets every value to zero

Open
#233 9 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

suggestion
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.