Skip to content

feat: add zero() method to Summary (#481) - #857

Open
Afnan-0206 wants to merge 1 commit into
prometheus:mainfrom
Afnan-0206:afnan/summary-zero
Open

Afnan-0206 wants to merge 1 commit into
prometheus:mainfrom
Afnan-0206:afnan/summary-zero

Conversation

@Afnan-0206

Copy link
Copy Markdown

Summary

Adds .zero(labels) to Summary metrics, bringing API and feature parity with Histogram.prototype.zero().

Motivation

Issue #481 identified that Summary lacked the ability to initialize a known label combination to zero before observations occur.
This can be useful when applications want metric series to exist before the first observation.

Implementation

  • Added Summary.prototype.zero(labels).
  • Reused a shared createBaseValues() helper for Summary storage initialization.
  • Added TypeScript declaration for Summary.zero().
  • Added tests covering:
    • zero-valued quantiles
    • zero sum
    • zero count
    • export before observations
    • subsequent observations
    • resetting an existing label combination
    • invalid labels

Testing

  • npx jest test/summaryTest.js
  • npm run lint
  • npm run check-prettier
  • npm run compile-typescript
  • npm test

All local validation passed.

Related Issue

Closes #481

Add Summary.prototype.zero(labels) to initialize a labelled Summary metric to zero across all quantiles, sum, and count prior to observations, matching Histogram.prototype.zero().

Signed-off-by: Afnan-0206 <2102508519@svyasa-sas.edu.in>

This branch has not been deployed

No deployments
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.

Should Summary have a .zero function?

1 participant