Skip to content

Escape exemplar label names using the negotiated scheme - #1243

Open
JackyHsu-X wants to merge 1 commit into
prometheus:masterfrom
JackyHsu-X:fix/exemplar-label-name-escaping
Open

JackyHsu-X wants to merge 1 commit into
prometheus:masterfrom
JackyHsu-X:fix/exemplar-label-name-escaping

Conversation

@JackyHsu-X

Copy link
Copy Markdown

Exemplar label names currently bypass the negotiated escaping scheme. For example, Counter.inc(exemplar={'trace.id': 'abc'}) is accepted but produces {trace.id="abc"} even with escaping=allow-utf-8; the OpenMetrics parser rejects that unquoted name.

Use the existing escape_label_name helper for exemplars, passing the selected scheme through both the classic and native histogram paths. This quotes extended names for allow-utf-8 and encodes them for the other schemes, consistently with sample labels. Label values keep their existing escaping.

Regression coverage exercises counters, classic histograms and native histograms, both supported exposition versions, all four schemes, Unicode and quoted names, plus an unchanged legacy-name control. This changes the emitter; #1230 concerns the separate parser handling of escaped quotes.

Validation: all five installed supported CPython versions (3.10–3.14) ran the full suite: 473 passed, 14 skipped each. The final regression matrix gives 40 failures and five passing controls with the original emitter, and 45 passes with this fix. Repository flake8/isort and mypy targeting Linux pass; native Windows mypy reports the same two process_collector.py platform-API errors on the original base and the fix. Actual HTTP negotiation passed 16 cases each on Windows and Linux. Optional integration skips, CPython 3.9, PyPy and macOS are not covered by that full-suite result.

@csmarchbanks

AI assistance: OpenAI Codex investigated, implemented and tested this change and drafted this description. No human review is claimed.

Signed-off-by: JackyHsu-X <xv1070733106@gmail.com>

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