Skip to content

Honor Accept quality values when choosing the metrics format - #1222

Open
zhechen-cs wants to merge 1 commit into
prometheus:masterfrom
zhechen-cs:codex/accept-quality
Open

zhechen-cs wants to merge 1 commit into
prometheus:masterfrom
zhechen-cs:codex/accept-quality

Conversation

@zhechen-cs

Copy link
Copy Markdown

choose_encoder() picks the first supported format without checking its quality value. For example, Accept: application/openmetrics-text;version=1.0.0;q=0, text/plain;version=1.0.0 currently returns OpenMetrics even though the client rejects it. A lower-quality format also wins if it appears first.

Select supported formats in descending quality order, skip zero or invalid weights, and preserve header order for ties. This also lets explicitly preferred legacy text output win over lower-quality OpenMetrics output. The existing text fallback remains available when no supported format matches.

Validation: the new regressions fail on the unmodified base. After the fix, the full suite passes with 431 tests passed and 14 skipped; tox -e flake8,isort,mypy passes. Local HTTP tests used NO_PROXY=localhost,127.0.0.1,::1 because the configured proxy returns 502 for local requests, including on the clean base.

@csmarchbanks

Signed-off-by: Zhe Chen <zhechen.cs@connect.hku.hk>

This branch has not been deployed

No deployments
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