feat: move suffix handling to scrape time with OTel preserve_names#1947
Draft
zeitlinger wants to merge 1 commit intomainfrom
Draft
feat: move suffix handling to scrape time with OTel preserve_names#1947zeitlinger wants to merge 1 commit intomainfrom
zeitlinger wants to merge 1 commit intomainfrom
Conversation
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) - OTel: legacy path strips _total + unit; preserve_names=true passes names through exactly as the user wrote them - 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) - Add preserve_names config to ExporterOpenTelemetryProperties - 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>
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
Moves metric name suffix handling (
_total,_info, unit suffixes) from creation time to scrape time. Closes #1941, part of #1942._total+ unit suffix;preserve_names=truepasses names through exactly as the user wrote themKey changes
PrometheusNamingMetricMetadata(originalNamevsexpositionBaseName)preserve_namesconfig toExporterOpenTelemetryProperties_totaland_infoPrometheusRegistry(base name + exposition names)Key table
Counter("events")events_totaleventseventsCounter("events_total")events_totaleventsevents_totalCounter("req").unit(BYTES)req_bytes_totalreq, unitByreq, unitByCounter("req_bytes").unit(BYTES)req_bytes_totalreq, unitByreq_bytes, unitByGauge("events_total")events_totalevents_totalevents_totalTest plan
mise run buildpasses (formatting, static analysis, checkstyle)mise run testpasses (all unit tests)MetricMetadata5-arg constructor and field accessorspreserve_names=truewith units, with unit already in name, and without unitPrometheusRegistryTestcovers collision detectionmise run test-all)mise run acceptance-test)