Skip to content

Count NaN histogram observations in the +Inf bucket - #1225

Merged
csmarchbanks merged 1 commit into
prometheus:masterfrom
zhechen-cs:codex/histogram-nan-count
Oct 30, 2026
Merged

csmarchbanks merged 1 commit into
prometheus:masterfrom
zhechen-cs:codex/histogram-nan-count

Conversation

@zhechen-cs

Copy link
Copy Markdown
Contributor

Histogram.observe(float('nan')) updates the sum but increments no bucket, so both _count and the +Inf bucket omit the observation. Count these observations in the overflow bucket while retaining the NaN sum and leaving finite bucket counts unchanged. This matches the classic-histogram handling described in the Prometheus histogram specification.

Added regressions for ordinary histograms and aggregation from two multiprocess metric files. Both fail on the unmodified base.

Validation on macOS / Python 3.12:

  • Targeted histogram and multiprocess tests: 48 passed.
  • Full suite: 443 passed, 1 skipped, 28 subtests passed.
  • tox -e flake8,isort,mypy and git diff --check: passed.

Local HTTP tests used NO_PROXY=localhost,127.0.0.1,::1 to bypass the local proxy; the proxy's HTTP 502 failure also reproduces on the unmodified base.

@csmarchbanks

Signed-off-by: Zhe Chen <zhechen.cs@connect.hku.hk>

@csmarchbanks csmarchbanks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@csmarchbanks
csmarchbanks merged commit 2301464 into prometheus:master Oct 30, 2026
2 of 13 checks passed
@zhechen-cs
zhechen-cs deleted the codex/histogram-nan-count branch November 5, 2026 12:32
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.

2 participants