feat: add OTel preserve_names for scrape-time suffix handling#1956
Open
zeitlinger wants to merge 5 commits intomainfrom
Open
feat: add OTel preserve_names for scrape-time suffix handling#1956zeitlinger wants to merge 5 commits intomainfrom
zeitlinger wants to merge 5 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
Move metric name suffix handling (_total, _info, unit suffixes) from creation time to scrape time. Each format writer now owns its suffix conventions: - OM1: smart-appends suffixes (skip if already present) - Registry detects cross-format name collisions at registration time Key changes: - Remove all reserved metric name suffixes from PrometheusNaming - Store original user-provided name separately from exposition base name in MetricMetadata (originalName vs expositionBaseName) - Smart-append logic in OM1/protobuf writers for _total and _info - Two-layer collision detection in PrometheusRegistry Closes #1941 Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
- Fix race condition: use putIfAbsent for atomic exposition name claiming with proper rollback on failure - Extract claimExpositionNames/releaseExpositionNames for single rollback path - Rename Info test methods to reflect that _info suffix is now allowed Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
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>
d89df06 to
5f80626
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.