fix: restore reserved suffix stripping in PrometheusNaming.sanitizeMetricName()#2124
Open
zeitlinger wants to merge 1 commit into
Open
fix: restore reserved suffix stripping in PrometheusNaming.sanitizeMetricName()#2124zeitlinger wants to merge 1 commit into
PrometheusNaming.sanitizeMetricName()#2124zeitlinger wants to merge 1 commit into
Conversation
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
This was referenced May 18, 2026
jaydeluca
approved these changes
May 19, 2026
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.
Fixes #2087.
Supersedes #2094 with the same fix on a clean, signed-off commit so the DCO
check can pass.
sanitizeMetricName()was simplified in 1.6.0 to return its input unchangedbecause any non-empty UTF-8 string is now a valid metric name. That silently
broke downstream tools — notably the JMX Exporter and the simpleclient bridge —
that call
sanitizeMetricName()to normalize external names before passing themto snapshot builders.
The missing stripping means a JMX attribute that produces
kafka_consumer_request_totalas a raw name is no longer sanitized tokafka_consumer_request. WithinferCounterTypeFromName: truethis triggersunintended counter-type inference; with it
falsethe metric is stored under thewrong name, breaking exact-name registry lookups.
Changes
RESERVED_METRIC_NAME_SUFFIXESand the iterative suffix-stripping loopin
PrometheusNaming.sanitizeMetricName()."_total"->"total", in a dedicatedpre-pass before the stripping loop.
PrometheusNamingTestandMetricMetadataTestexpectations.case, for example
.total.Counter.builder().name("events_total")is unaffected because the builder APIdoes not go through
sanitizeMetricName().Validation
mise run build