feat: implement summary support for OpenMetrics 2.0 - #983
Open
dashpole wants to merge 2 commits into
Open
Conversation
Implement serialization and strict validation for summaries 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.
🟡 Changes recommended
The new summary validation rejects negative SampleSum and negative quantile values, which are valid in existing OpenMetrics summary behavior and would cause the OM2.0 encoder to error on legitimate data.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds OpenMetrics 2.0 composite summary support to expfmt by implementing serialization plus validation, and expands the test suite to cover correct formatting and error cases.
Changes:
- Implement
writeCompositeSummaryfor OpenMetrics 2.0 composite summary encoding, including label/quantile/timestamp validation. - Update OpenMetrics 2.0 encoder documentation comment to reflect newly supported metric types.
- Add comprehensive summary test vectors (success + validation errors + “no partial bytes on error”).
File summaries
| File | Description |
|---|---|
| expfmt/openmetrics_2_0_create.go | Implements OpenMetrics 2.0 composite summary encoding and validation logic. |
| expfmt/openmetrics_2_0_create_test.go | Adds summary golden tests, validation error tests, and a no-partial-bytes regression test. |
Review details
Suppressed comments (1)
expfmt/openmetrics_2_0_create.go:386
- Rejecting negative quantile values for summaries is likely incorrect: quantile values are observed sample values and can be negative (the OpenMetrics v1.0 encoder tests include negative quantile values). This validation would cause the OM2.0 encoder to error on otherwise valid summary data.
v := q.GetValue()
if !math.IsNaN(v) && v < 0 {
return 0, fmt.Errorf("summary quantile value cannot be negative (%g) in metric %s", v, name)
}
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 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
September 2, 2026 16:49
…ic families accepted by other formats Signed-off-by: David Ashpole <dashpole@google.com>
dashpole
force-pushed
the
om2_summaries
branch
from
September 8, 2026 15:46
242b0e7 to
f5103d4
Compare
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
Implement serialization and strict validation for summaries in OpenMetrics 2.0 format according to the specification and ABNF grammar.
Benchmark Results