feat: implement histogram and gauge histogram support for OpenMetrics 2.0 - #964
Draft
dashpole wants to merge 3 commits into
Draft
feat: implement histogram and gauge histogram support for OpenMetrics 2.0#964dashpole wants to merge 3 commits into
dashpole wants to merge 3 commits into
Conversation
… 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>
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.
Signed-off-by: David Ashpole <dashpole@google.com>
Signed-off-by: David Ashpole <dashpole@google.com>
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.