Skip to content

fix: support exemplars with empty label sets in OpenMetrics 2.0 - #965

Open
dashpole wants to merge 1 commit into
prometheus:mainfrom
dashpole:om2_empty_label_exemplar_fix
Open

fix: support exemplars with empty label sets in OpenMetrics 2.0#965
dashpole wants to merge 1 commit into
prometheus:mainfrom
dashpole:om2_empty_label_exemplar_fix

Conversation

@dashpole

@dashpole dashpole commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

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:

"Exemplars without Labels MUST represent an empty LabelSet as {}."

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
dashpole marked this pull request as ready for review August 21, 2026 19:06
@dashpole
dashpole requested review from bwplotka and krajorama August 21, 2026 19:07
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