Skip to content

expfmt: support Prometheus text format 1.0.0 - #1035

Merged
SuperQ merged 2 commits into
prometheus:mainfrom
ArthurSens:codex/prometheus-text-1-negotiation
Nov 11, 2026
Merged

SuperQ merged 2 commits into
prometheus:mainfrom
ArthurSens:codex/prometheus-text-1-negotiation

Conversation

@ArthurSens

@ArthurSens ArthurSens commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Prometheus requests UTF-8 metric names using text/plain;version=1.0.0;escaping=allow-utf-8, but the default accepted formats only support text version 0.0.4. This causes negotiation to select 0.0.4 and underscore-escape names despite the scraper supporting UTF-8.

Add Prometheus text format 1.0.0 support to negotiation, encoding, and decoding, while preserving the existing 0.0.4 fallback.

Related: open-telemetry/opentelemetry-collector-contrib#52781

Assisted-by: Codex (GPT-6)
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
@ArthurSens
ArthurSens force-pushed the codex/prometheus-text-1-negotiation branch from b35cd14 to f382e0f Compare November 6, 2026 20:28
@ArthurSens
ArthurSens marked this pull request as ready for review November 6, 2026 20:30
Comment thread expfmt/decode.go Outdated

case textType:
if params["version"] == TextVersion_1_0_0 {
return FmtText_1_0_0.WithEscapingScheme(Format(ct).ToEscapingScheme())

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.

Calling WithEscapingScheme unconditionally here makes ResponseFormat append ; escaping=underscores even when Content-Type: text/plain; version=1.0.0 has no escaping parameter, unlike all other formats returned by ResponseFormat. Could we only attach WithEscapingScheme when params[model.EscapingKey] is present (or do that consistently across all formats in ResponseFormat so NewDecoder preserves escaping for OpenMetrics and protobuf too)?

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
@SuperQ

SuperQ commented Nov 10, 2026

Copy link
Copy Markdown
Member

There's a Prometheus 1.0.0 text format?

I don't see it documented: https://prometheus.io/docs/instrumenting/exposition_formats/

gjed added a commit to gjed/github-activity-exporter that referenced this pull request Nov 10, 2026
v0.73.0 (prometheus/common#1008) takes the escaping
scheme only from the matching Accept clause. expfmt negotiates only text
0.0.4, so the Prometheus 3.x default scrape gets escaping=underscores and
/metrics serves underscored names instead of pure OTel names. Hold until
prometheus/common#1035 lands.
@SuperQ
SuperQ merged commit 2d68004 into prometheus:main Nov 11, 2026
8 checks passed
@SuperQ SuperQ mentioned this pull request Nov 11, 2026
@krajorama

Copy link
Copy Markdown
Member

There's a Prometheus 1.0.0 text format?

I don't see it documented: https://prometheus.io/docs/instrumenting/exposition_formats/

PR to add: prometheus/docs#3183

SuperQ added a commit that referenced this pull request Nov 12, 2026
What's Changed
* expfmt: add ABNF parser for OpenMetrics 2.0 by @bwplotka in #1016
* build(deps): bump ossf/scorecard-action from 2.4.4 to 2.5.0 by @dependabot[bot] in #1032
* build(deps): bump actions/upload-artifact from 7.0.1 to 7.0.2 by @dependabot[bot] in #1033
* build(deps): bump golang.org/x/net from 0.61.0 to 0.62.0 in the golang-org-x group across 1 directory by @dependabot[bot] in #1030
* expfmt: bump go-abnf to v0.5.5 by @PerryLink in #1029
* config: move Secret into its own package by @mrueg in #1024
* build(deps): bump the codeql group with 4 updates by @dependabot[bot] in #1031
* version: fix Slog godoc example to compile by @sueun-dev in #935
* build(deps): bump go.yaml.in/yaml/v2 from 2.4.4 to 2.4.5 by @dependabot[bot] in #1043
* build(deps): bump golang.org/x/oauth2 from 0.37.0 to 0.38.0 in the golang-org-x group across 1 directory by @dependabot[bot] in #1042
* expfmt: support Prometheus text format 1.0.0 by @ArthurSens in #1035

New Contributors
* @PerryLink made their first contribution in #1029
* @sueun-dev made their first contribution in #935

**Full Changelog**: v0.73.1...v0.74.0

Signed-off-by: SuperQ <superq@gmail.com>
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.

4 participants