Skip to content

feat: bind exposition writers to negotiated escaping - #2642

Merged
zeitlinger merged 6 commits into
mainfrom
fix/negotiated-exposition
Nov 25, 2026
Merged

zeitlinger merged 6 commits into
mainfrom
fix/negotiated-exposition

Conversation

@zeitlinger

@zeitlinger zeitlinger commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

I added an immutable ExpositionFormatWriterWithEscaping wrapper and a factory that binds the selected format to the escaping scheme negotiated from the Accept header. The scrape handler now uses the negotiated writer, while the existing writer API and standard content types remain unchanged. Fixes #1577.

I added the generated API diff report and normalized its generator to omit trailing blank lines rejected by lint. Lint and unit tests pass. The local mise run build reached integration tests but Docker/Testcontainers failures prevented the full build; the install build with integration tests skipped passed.

I also documented manual negotiated responses in the Formats guide.

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

⚠️ API changes detected — maintainer review required

This PR modifies the published API diff for the following module(s):

  • prometheus-metrics-exposition-textformats

Please review the changes in docs/apidiffs/current_vs_latest/ carefully before approving.

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger
zeitlinger marked this pull request as ready for review November 6, 2026 15:24

@jaydeluca jaydeluca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks — this matches the shape sketched in #1577, and moving the OM2 fallback into
ExpositionFormats means manual callers get it too, not just the scrape handler.

  1. Escaping is still parsed from the whole Accept header rather than the selected media type
    (inline below). Pre-existing, but this method now promises both come from one negotiation.
  2. A couple of small javadoc/test wording nits.

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger
zeitlinger merged commit 92c50f8 into main Nov 25, 2026
23 checks passed
@zeitlinger
zeitlinger deleted the fix/negotiated-exposition branch November 25, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Escaping API inconsistencies

2 participants