feat: implement histogram and gauge histogram support for OpenMetrics 2.0 - #964
Open
dashpole wants to merge 13 commits into
Open
feat: implement histogram and gauge histogram support for OpenMetrics 2.0#964dashpole wants to merge 13 commits into
dashpole wants to merge 13 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the OpenMetrics 2.0 encoder to support serialization and validation of histogram and gauge-histogram metrics, aligning output formatting with the OM2 structure (inline histogram fields plus optional exemplars), and adjusts exemplar emission rules to allow empty-label exemplars when a timestamp is present.
Changes:
- Implemented OpenMetrics 2.0 serialization/validation for classic, native, dual, and gauge histograms (including spans/buckets encoding and created timestamps where applicable).
- Updated exemplar handling to no longer drop exemplars solely due to having an empty label set (still dropped if missing timestamp), emitting
{}for empty labels. - Added comprehensive golden/output and error-case test coverage for histogram variants in OM2.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| expfmt/openmetrics_2_0_create.go | Implements histogram/gaugehistogram encoding + validation and updates exemplar formatting for empty-label exemplars. |
| expfmt/openmetrics_2_0_create_test.go | Adds output and error tests covering classic/native/dual/gauge histogram serialization and validation rules. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
bwplotka
approved these changes
Aug 24, 2026
bwplotka
left a comment
Member
There was a problem hiding this comment.
Looks solid, so far, thanks, some nits
dashpole
force-pushed
the
om2_histograms
branch
2 times, most recently
from
August 24, 2026 18:18
75927dd to
e391204
Compare
… 2.0 Implement serialization and strict validation for classic, native, dual, and gauge histograms in OpenMetrics 2.0 format according to the specification and ABNF grammar. Signed-off-by: David Ashpole <dashpole@google.com>
Signed-off-by: David Ashpole <dashpole@google.com>
Signed-off-by: David Ashpole <dashpole@google.com>
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com> Signed-off-by: David Ashpole <dashpole@google.com>
Signed-off-by: David Ashpole <dashpole@google.com>
…ncoding Signed-off-by: David Ashpole <dashpole@google.com>
…ram encoding Signed-off-by: David Ashpole <dashpole@google.com>
Signed-off-by: David Ashpole <dashpole@google.com>
…m encoding Signed-off-by: David Ashpole <dashpole@google.com>
Signed-off-by: David Ashpole <dashpole@google.com>
… in OM 2.0 Signed-off-by: David Ashpole <dashpole@google.com>
…dBuckets Signed-off-by: David Ashpole <dashpole@google.com>
Signed-off-by: David Ashpole <dashpole@google.com>
dashpole
force-pushed
the
om2_histograms
branch
from
August 26, 2026 13:52
e391204 to
18756bb
Compare
dashpole
marked this pull request as ready for review
August 26, 2026 14:31
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 2 of #893
Implement serialization and strict validation for classic, native, dual, and gauge histograms in OpenMetrics 2.0 format according to the specification and ABNF grammar.