FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Parse the native histogram sum as a float by sean-kim05 · Pull Request #1192 · prometheus/client_python · GitHub

Parse the native histogram sum as a float - #1192

Merged
csmarchbanks merged 1 commit into
prometheus:masterfrom
sean-kim05:fix/native-histogram-float-sum
Jul 24, 2026
Merged

Parse the native histogram sum as a float#1192
csmarchbanks merged 1 commit into
prometheus:masterfrom
sean-kim05:fix/native-histogram-float-sum

Conversation

Copy link
Copy Markdown
Contributor

_parse_nh_struct parsed the sum field with int(), so a native histogram
whose sum is not integral failed to parse with

ValueError: invalid literal for int() with base 10: '100.5'

NativeHistogram.sum_value is a float and the OpenMetrics writer emits the
sum verbatim (e.g. sum:100.5), so the library could not parse its own
output for the common case of a non-integer sum. Parse sum with float()
to match; count, schema and zero_count remain int as they are genuinely
integers.

Add test_native_histogram_float_sum, which parses a native histogram
with a fractional sum and checks it round-trips to sum_value 100.5.

@csmarchbanks

_parse_nh_struct parsed the sum field with int(), so a native histogram
whose sum is not integral failed to parse with

    ValueError: invalid literal for int() with base 10: '100.5'

NativeHistogram.sum_value is a float and the OpenMetrics writer emits the
sum verbatim (e.g. sum:100.5), so the library could not parse its own
output for the common case of a non-integer sum. Parse sum with float()
to match; count, schema and zero_count remain int as they are genuinely
integers.

Add test_native_histogram_float_sum, which parses a native histogram
with a fractional sum and checks it round-trips to sum_value 100.5.

Signed-off-by: Sean Kim <skim8705@gmail.com>

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks!

csmarchbanks merged commit 5b09479 into prometheus:master Jul 24, 2026
12 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL