fix: support exemplars with empty label sets in OpenMetrics 2.0 - #965
Open
dashpole wants to merge 1 commit into
Open
fix: support exemplars with empty label sets in OpenMetrics 2.0#965dashpole wants to merge 1 commit into
dashpole wants to merge 1 commit into
Conversation
OpenMetrics 2.0 specification allows exemplars with an empty label set ({}). Previously, exemplars without labels were dropped.
Signed-off-by: David Ashpole <dashpole@google.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the OpenMetrics 2.0 text encoder to correctly serialize exemplars that have a valid timestamp but an empty label set ({}), aligning behavior with the OpenMetrics 2.0 specification (Issue #893). Previously, exemplars without labels were silently dropped.
Changes:
- Stop dropping exemplars solely because they have zero labels; only drop exemplars without a timestamp.
- Emit
{}explicitly for empty exemplar label sets (instead of emitting nothing). - Add a regression test covering a counter exemplar with no labels.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
expfmt/openmetrics_2_0_create.go |
Allows exemplars with empty label sets and ensures they serialize as {} when timestamp is present. |
expfmt/openmetrics_2_0_create_test.go |
Adds coverage for exemplars with empty label sets to prevent regressions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
dashpole
marked this pull request as ready for review
August 21, 2026 19:06
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 of #893
Split out of #964
OpenMetrics 2.0 specification represents exemplars with an empty label set ({}). Previously, exemplars without labels were dropped. From the spec: