Skip to content

fix: drop invalid OpenMetrics 2.0 exemplars instead of failing exposition - #970

Open
dashpole wants to merge 2 commits into
prometheus:mainfrom
dashpole:fix-om20-exemplars
Open

fix: drop invalid OpenMetrics 2.0 exemplars instead of failing exposition#970
dashpole wants to merge 2 commits into
prometheus:mainfrom
dashpole:fix-om20-exemplars

Conversation

@dashpole

@dashpole dashpole commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Small follow-up to #894.

Per the OpenMetrics 2.0 specification failure modes, failures specific to exemplars should not cause the entire exposition to fail. Invalid exemplars (e.g. invalid timestamps, malformed labels) are now dropped so that the rest of the metric exposition succeeds.

"This specification advocates for transactional processing: any encoding, decoding, or validation errors must reject the whole MetricSet ingestion. A failed scrape is better than an inaccurate scrape or a partial metric view that breaks transactionality (e.g., scraping a portion of a StateSet MetricGroup, or scraping only one Counter out of two that are aggregated in a single alert expression).

There's one exception to this rule: failures specific to exemplars should not cause the entire exposition to fail. If an exemplar is malformed or invalid, it should be dropped or ignored, allowing the valid metric data to be ingested."

This also consolidates exemplar timestamp validation in validateExemplar20.

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

Updates OpenMetrics 2.0 exposition handling to drop invalid exemplars while preserving valid metric output.

Changes:

  • Centralizes exemplar timestamp validation.
  • Drops exemplars with invalid timestamps or labels.
  • Adds regression coverage for invalid exemplars.

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 Implements exemplar validation and dropping behavior.
expfmt/openmetrics_2_0_create_test.go Tests invalid exemplar handling.

💡 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 24, 2026 17:03
@dashpole
dashpole requested review from bwplotka and krajorama August 24, 2026 17:04
Comment thread expfmt/openmetrics_2_0_create.go
…tion

Per the OpenMetrics 2.0 specification failure modes, failures specific
to exemplars should not cause the entire exposition to fail. Invalid
exemplars (e.g. invalid timestamps, malformed labels) are now dropped
so that the rest of the metric exposition succeeds.

Signed-off-by: David Ashpole <dashpole@google.com>
@dashpole
dashpole force-pushed the fix-om20-exemplars branch from 4813e7a to b4b469e Compare August 24, 2026 17:34
…are dropped

Signed-off-by: David Ashpole <dashpole@google.com>
@dashpole
dashpole force-pushed the fix-om20-exemplars branch from b4b469e to 223e26b Compare August 24, 2026 17:36
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