Skip to content

Add native histogram support#304

Open
howardjohn wants to merge 3 commits into
prometheus:masterfrom
howardjohn:histogram/native2
Open

Add native histogram support#304
howardjohn wants to merge 3 commits into
prometheus:masterfrom
howardjohn:histogram/native2

Conversation

@howardjohn

Copy link
Copy Markdown
Contributor

This PR adds support for native histograms using the new prometheus protobuf support recently merged.

The implementation is basically 1:1 lifted from the Golang implementation as much as possible, including tests.

Users can make any of the 3: classic only, native only, or classic + native histogram.

Add native-only histograms and histograms that expose both classic and native buckets. Encode native sparse bucket spans and deltas through the Prometheus protobuf encoder while keeping text and OpenMetrics protobuf behavior on the classic representation when available.

Signed-off-by: John Howard <john.howard@solo.io>
@howardjohn howardjohn force-pushed the histogram/native2 branch from dc631bf to d4882eb Compare May 28, 2026 20:55
@f41gh7

f41gh7 commented May 29, 2026

Copy link
Copy Markdown

Related issue #150

@krisztianfekete krisztianfekete left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks great, I am planning to do some actual testing as well soon, but added a couple of comments/questions in the meantime!

Comment thread src/metrics/histogram.rs
Comment thread src/metrics/histogram.rs Outdated
Comment thread src/metrics/histogram.rs Outdated
Comment thread src/metrics/histogram.rs Outdated
Comment thread src/encoding/text.rs
Comment thread src/metrics/histogram.rs
Comment thread src/metrics/histogram.rs
Signed-off-by: John Howard <john.howard@solo.io>

@krisztianfekete krisztianfekete left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Awesome work, all looks good to me! We are matching client_golang for all edge cases as far as I can see. We also have a nice test coverage (even more granular at some places), maybe outside of exemplars (we can do that as a follow-up). Also did some local testing, and can confirm the same.

Added one comment about doing the version bump separately, otherwise LGTM!

Comment thread Cargo.toml Outdated
[package]
name = "prometheus-client"
version = "0.25.0"
version = "0.26.0"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you please revert this back to 0.25.0, and move the changelog entry to unreleased to follow the previous release conventions (e.g. 4a6d40a)?

Signed-off-by: John Howard <john.howard@solo.io>
@howardjohn howardjohn force-pushed the histogram/native2 branch from c5de02d to 490bcc8 Compare June 8, 2026 15:14
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.

3 participants