Skip to content

feat: add OTel preserve_names for scrape-time suffix handling#1956

Merged
zeitlinger merged 3 commits intomainfrom
scrape-time-suffix-otel
Mar 20, 2026
Merged

feat: add OTel preserve_names for scrape-time suffix handling#1956
zeitlinger merged 3 commits intomainfrom
scrape-time-suffix-otel

Conversation

@zeitlinger
Copy link
Member

@zeitlinger zeitlinger commented Mar 17, 2026

Summary

Adds preserve_names configuration to the OpenTelemetry exporter.
When enabled, metric names are passed through exactly as the user
wrote them instead of stripping _total and unit suffixes.
Part of #1942.

Key changes

  • Add preserve_names to ExporterOpenTelemetryProperties
  • MetricDataFactory uses originalName + preserve_names to
    decide naming
  • OtelAutoConfig wires the new property

Key table

User provides OTel OTel preserve_names
Counter("events") events events
Counter("events_total") events events_total
Counter("req").unit(BYTES) name req, unit By name req, unit By
Counter("req_bytes").unit(BYTES) name req, unit By name req_bytes, unit By
Gauge("events_total") events_total events_total

PR stack

  1. Core model + OM1/protobuf writers (feat: move suffix handling to scrape time #1955)
  2. This PR — OTel preserve_names
  3. OM2 writer no-suffix (independent)

Test plan

  • mise run compile passes
  • Tests for preserve_names=true with units, unit already in
    name, and without unit
  • OtelAutoConfigTest covers new property wiring

Part of #1912.

@zeitlinger zeitlinger changed the base branch from scrape-time-suffix-core to main March 17, 2026 10:32
@zeitlinger zeitlinger marked this pull request as ready for review March 17, 2026 10:32
Add preserve_names configuration to the OpenTelemetry exporter. When
enabled, metric names are passed through exactly as the user wrote them
instead of stripping _total and unit suffixes.

- Add preserve_names to ExporterOpenTelemetryProperties
- MetricDataFactory uses originalName + preserve_names to decide naming
- OtelAutoConfig wires the new property
- Tests for preserve_names with units, unit-in-name, and without unit

Part of #1942
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
…ests

Avoids brittle reflective access to OpenTelemetryExtension internals.
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger zeitlinger force-pushed the scrape-time-suffix-otel branch from 9cbe09d to c822baf Compare March 20, 2026 09:40
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger zeitlinger merged commit f794288 into main Mar 20, 2026
13 checks passed
@zeitlinger zeitlinger deleted the scrape-time-suffix-otel branch March 20, 2026 11:34
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.

2 participants