Skip to content

expfmt: add NegotiateFormatsIncludingOpenMetrics#951

Open
dpacgdm wants to merge 1 commit into
prometheus:mainfrom
dpacgdm:feat/negotiate-formats-including-openmetrics
Open

expfmt: add NegotiateFormatsIncludingOpenMetrics#951
dpacgdm wants to merge 1 commit into
prometheus:mainfrom
dpacgdm:feat/negotiate-formats-including-openmetrics

Conversation

@dpacgdm

@dpacgdm dpacgdm commented Jul 21, 2026

Copy link
Copy Markdown

Summary

  • Add NegotiateFormatsIncludingOpenMetrics returning all recognised Accept formats in preference order
  • Keep NegotiateIncludingOpenMetrics as a wrapper that returns the first entry
  • Add a regression test for proto → OpenMetrics → text fallback

Addresses #928. This gives servers that support only a subset of formats a clean way to walk the client's preference list (example in the issue: protobuf preferred but unsupported → OpenMetrics → text).

Callers such as kube-state-metrics can use this for content negotiation; a local workaround is also possible without this API.

Test plan

  • go test ./expfmt/ -run Negotiate

@dpacgdm
dpacgdm force-pushed the feat/negotiate-formats-including-openmetrics branch 2 times, most recently from fe28cc9 to 34cf5a7 Compare July 21, 2026 15:34
NegotiateIncludingOpenMetrics only returns the top Accept match, so
servers that lack that format cannot fall back to the next recognised
option without reimplementing negotiation. Return the full ordered list
and keep the existing single-format helper as a thin wrapper.

Signed-off-by: dpacgdm <dpac.gdm@gmail.com>
@dpacgdm
dpacgdm force-pushed the feat/negotiate-formats-including-openmetrics branch from 34cf5a7 to 563548c Compare July 21, 2026 15: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.

1 participant