Skip to content

Don't zero out Gauges. - #813

Open
jdmarshall wants to merge 2 commits into
prometheus:mainfrom
jdmarshall:gaugeZero
Open

Don't zero out Gauges. #813
jdmarshall wants to merge 2 commits into
prometheus:mainfrom
jdmarshall:gaugeZero

Conversation

@jdmarshall

@jdmarshall jdmarshall commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

This PR started as exploratory work for a different issue - there's been a TODO that I added to metric.js that fights the work needed for #812. I had already decided that doing #812 all in a single PR would probably get a little bit on the long side, so I was looking for some stopping point in the middle to split it up.

I noticed that if #622 were fixed, then a default reset() implementation would be used by 2 of the 4 builtin metric types.

This PR initializes the store in metrics.js, and then retains the LabelMap object across reset() calls, and removes the zeroing logic from Gauge.reset(), thereby fixing #622.

Signed-off-by: Jason Marshall <jdmarshall@users.noreply.github.com>
Also does some lifecycle work for how and when stores are initialized, in
preparation for more extensive changes for prometheus#812

Fixes prometheus#622

Signed-off-by: Jason Marshall <jdmarshall@users.noreply.github.com>
@jdmarshall jdmarshall added this to the v1 milestone Aug 21, 2026
Comment thread CHANGELOG.md

### Added

## [0.16.0] - 2026-08-??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This got picked up from another PR that needs to land for v0.16.0

Comment thread lib/metric.js
throw new Error('Optional "collect" parameter must be a function');
}

if (this.labelNames) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So my IDE is telling me we don't use these values anymore, and with the LabelMap call right below this (which also does this sort) and the deprecations in util.js, it's looking more and more like we can just drop these. Which would also be a little more memory for #800

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

Successfully merging this pull request may close these issues.

1 participant