feat: add OTel preserve_names for scrape-time suffix handling#1956
Merged
zeitlinger merged 3 commits intomainfrom Mar 20, 2026
Merged
feat: add OTel preserve_names for scrape-time suffix handling#1956zeitlinger merged 3 commits intomainfrom
zeitlinger merged 3 commits intomainfrom
Conversation
7 tasks
jaydeluca
reviewed
Mar 17, 2026
...heus-metrics-model/src/test/java/io/prometheus/metrics/model/snapshots/InfoSnapshotTest.java
Outdated
Show resolved
Hide resolved
...eus-metrics-model/src/main/java/io/prometheus/metrics/model/registry/PrometheusRegistry.java
Outdated
Show resolved
Hide resolved
...ter-opentelemetry/src/test/java/io/prometheus/metrics/exporter/opentelemetry/ExportTest.java
Outdated
Show resolved
Hide resolved
4 tasks
d89df06 to
5f80626
Compare
jaydeluca
approved these changes
Mar 18, 2026
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>
9cbe09d to
c822baf
Compare
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
preserve_namesconfiguration to the OpenTelemetry exporter.When enabled, metric names are passed through exactly as the user
wrote them instead of stripping
_totaland unit suffixes.Part of #1942.
Key changes
preserve_namestoExporterOpenTelemetryPropertiesMetricDataFactoryusesoriginalName+preserve_namestodecide naming
OtelAutoConfigwires the new propertyKey table
Counter("events")eventseventsCounter("events_total")eventsevents_totalCounter("req").unit(BYTES)req, unitByreq, unitByCounter("req_bytes").unit(BYTES)req, unitByreq_bytes, unitByGauge("events_total")events_totalevents_totalPR stack
preserve_namesTest plan
mise run compilepassespreserve_names=truewith units, unit already inname, and without unit
OtelAutoConfigTestcovers new property wiringPart of #1912.