fix: restore reserved suffix stripping in PrometheusNaming.sanitizeMetricName() by zeitlinger · Pull Request #2124 · prometheus/client_java (original) (raw)

@zeitlinger

Signed-off-by: Gregor Zeitlinger gregor.zeitlinger@grafana.com

This was referenced

May 18, 2026

jaydeluca

@zeitlinger zeitlinger deleted the fix/sanitize-metric-name-reserved-suffix branch

May 20, 2026 09:53

zeitlinger added a commit that referenced this pull request

May 22, 2026

@zeitlinger @jaydeluca

Draft validation PR for the unmodified Micrometer compatibility story.

This intentionally does not depend on #2114. Vanilla Micrometer does not use the typed descriptor API and does not implement the #1800 registration metadata hooks, so this PR validates the patch-compatible path independently of typed descriptors.

This validates upstream micrometer-metrics/micrometer@main against:

Local validation:


Signed-off-by: Gregor Zeitlinger gregor.zeitlinger@grafana.com Co-authored-by: Jay DeLuca jaydeluca4@gmail.com

zeitlinger added a commit that referenced this pull request

Jun 1, 2026

@zeitlinger

Adds typed metric family descriptors and typed metadata support for the model snapshots.

This is the typed-descriptor branch for downstreams that want to provide registration-time metadata explicitly. The #1800 Collector/MultiCollector registration metadata hooks are already optional via default methods, so unmodified downstreams should not need this PR just to keep working.

This PR now also deprecates the fragmented registration metadata API (getPrometheusName(), getMetricType(), getLabelNames(), and getMetadata() plus the MultiCollector variants) in favor of getMetricFamilyDescriptor() / getMetricFamilyDescriptors(). The deprecated methods remain bridged by default implementations for compatibility.

Related validation:


Signed-off-by: Gregor Zeitlinger gregor.zeitlinger@grafana.com

zeitlinger added a commit that referenced this pull request

Jun 3, 2026

@github-actions @zeitlinger

jaydeluca pushed a commit that referenced this pull request

Jun 4, 2026

@zeitlinger @jaydeluca

…etricName()` (#2124)

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 unchanged because 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 them to snapshot builders.

The missing stripping means a JMX attribute that produces kafka_consumer_request_total as a raw name is no longer sanitized to kafka_consumer_request. With inferCounterTypeFromName: true this triggers unintended counter-type inference; with it false the metric is stored under the wrong name, breaking exact-name registry lookups.

Changes

// Before fix: suffix preserved -> metric stored as "kafka_consumer_request_total"
PrometheusNaming.sanitizeMetricName("kafka_consumer_request_total");

// After fix: suffix stripped -> metric stored as "kafka_consumer_request"
PrometheusNaming.sanitizeMetricName("kafka_consumer_request_total");

Counter.builder().name("events_total") is unaffected because the builder API does not go through sanitizeMetricName().

Validation

Signed-off-by: Gregor Zeitlinger gregor.zeitlinger@grafana.com Signed-off-by: Jay DeLuca jaydeluca4@gmail.com

jaydeluca added a commit that referenced this pull request

Jun 4, 2026

@zeitlinger @jaydeluca

Draft validation PR for the unmodified Micrometer compatibility story.

This intentionally does not depend on #2114. Vanilla Micrometer does not use the typed descriptor API and does not implement the #1800 registration metadata hooks, so this PR validates the patch-compatible path independently of typed descriptors.

This validates upstream micrometer-metrics/micrometer@main against:

Local validation:


Signed-off-by: Gregor Zeitlinger gregor.zeitlinger@grafana.com Co-authored-by: Jay DeLuca jaydeluca4@gmail.com Signed-off-by: Jay DeLuca jaydeluca4@gmail.com

jaydeluca pushed a commit that referenced this pull request

Jun 4, 2026

@zeitlinger @jaydeluca

Adds typed metric family descriptors and typed metadata support for the model snapshots.

This is the typed-descriptor branch for downstreams that want to provide registration-time metadata explicitly. The #1800 Collector/MultiCollector registration metadata hooks are already optional via default methods, so unmodified downstreams should not need this PR just to keep working.

This PR now also deprecates the fragmented registration metadata API (getPrometheusName(), getMetricType(), getLabelNames(), and getMetadata() plus the MultiCollector variants) in favor of getMetricFamilyDescriptor() / getMetricFamilyDescriptors(). The deprecated methods remain bridged by default implementations for compatibility.

Related validation:


Signed-off-by: Gregor Zeitlinger gregor.zeitlinger@grafana.com Signed-off-by: Jay DeLuca jaydeluca4@gmail.com

jaydeluca pushed a commit that referenced this pull request

Jun 4, 2026

🤖 I have created a release beep boop

1.7.0 (2026-06-03)

Features

Bug Fixes

Performance Improvements

Documentation


[!IMPORTANT] Close and reopen this PR to trigger CI checks.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Gregor Zeitlinger gregor.zeitlinger@grafana.com Signed-off-by: Jay DeLuca jaydeluca4@gmail.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

[ Show hidden characters]({{ revealButtonHref }})