Skip to content

expfmt: fix OpenMetrics 2.0 decoder error, format docs, and encoder version dispatch - #968

Open
dashpole wants to merge 3 commits into
prometheus:mainfrom
dashpole:fix-om20-decoder-and-format
Open

expfmt: fix OpenMetrics 2.0 decoder error, format docs, and encoder version dispatch#968
dashpole wants to merge 3 commits into
prometheus:mainfrom
dashpole:fix-om20-decoder-and-format

Conversation

@dashpole

Copy link
Copy Markdown
Contributor

Some small follow-ups to the OpenMetrics 2.0 support introduced by #894.

  • Return unsupported format error in NewDecoder for OpenMetrics 2.0.
  • Clarify experimental encode-only status and ignored EncoderOptions in doc comments.
  • Use mime.ParseMediaType in NewEncoder to properly handle cases where a format or Content-Type header uses standard MIME quoting or spacing (e.g. application/openmetrics-text; version="2.0.0").

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 applies follow-up fixes and clarifications to the expfmt OpenMetrics 2.0 support introduced in #894, focusing on correct format/version dispatch, clearer “encode-only experimental” messaging, and more explicit decode behavior for OpenMetrics 2.0.

Changes:

  • Make NewEncoder (and NewDecoder for OpenMetrics) use mime.ParseMediaType so version parameters are correctly handled even with standard MIME quoting/spacing.
  • Return an explicit “not supported for decoding” error from NewDecoder for OpenMetrics version=2.0.0.
  • Clarify documentation around OpenMetrics 2.0’s experimental/encode-only status and option handling; add tests covering the new dispatch/error behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
expfmt/openmetrics_2_0_create.go Clarifies OpenMetrics 2.0 encoder documentation and explicitly ignores encoder options.
expfmt/expfmt.go Documents experimental/encode-only status in OpenMetrics format construction and comments.
expfmt/encode.go Uses mime.ParseMediaType to dispatch OpenMetrics encoding by version parameter reliably.
expfmt/encode_test.go Adds coverage ensuring OpenMetrics 2.0 encoder dispatch works with reordered/quoted MIME params.
expfmt/decode.go Returns an explicit unsupported decode error for OpenMetrics 2.0 based on version parameter.
expfmt/decode_test.go Adds coverage verifying NewDecoder errors for OpenMetrics 2.0 and succeeds/falls back elsewhere.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread expfmt/decode.go
Comment thread expfmt/openmetrics_2_0_create.go Outdated
@dashpole
dashpole force-pushed the fix-om20-decoder-and-format branch from 0fe3bb8 to 2b4b2f8 Compare August 24, 2026 16:40
dashpole and others added 3 commits August 24, 2026 17:50
…ersion dispatch

- Return unsupported format error in NewDecoder for OpenMetrics 2.0.
- Clarify experimental encode-only status and ignored EncoderOptions in doc comments.
- Use mime.ParseMediaType in NewEncoder for clean version dispatch.

Signed-off-by: David Ashpole <dashpole@google.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: David Ashpole <dashpole@google.com>
…0 doc comments

Signed-off-by: David Ashpole <dashpole@google.com>
@dashpole
dashpole force-pushed the fix-om20-decoder-and-format branch from 2b4b2f8 to 263defe Compare August 24, 2026 17:50
@dashpole
dashpole requested review from bwplotka and krajorama August 24, 2026 17:59
@dashpole
dashpole marked this pull request as ready for review August 24, 2026 17:59
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