Skip to content

Comments

Update Prometheus client to 1.5.0#8080

Open
zeitlinger wants to merge 1 commit intoopen-telemetry:mainfrom
zeitlinger:update-prom-client-simple
Open

Update Prometheus client to 1.5.0#8080
zeitlinger wants to merge 1 commit intoopen-telemetry:mainfrom
zeitlinger:update-prom-client-simple

Conversation

@zeitlinger
Copy link
Member

@zeitlinger zeitlinger commented Feb 13, 2026

Summary

Simplified replacement for #7588 - updates the Prometheus client from 1.3.10 to 1.5.0 without adding a UTF-8 support flag.

In Prometheus client 1.4.x+, sanitizeMetricName and sanitizeLabelName no longer convert non-standard characters (dots, dashes, non-ASCII) to underscores, since the client now supports UTF-8 natively. To maintain backward-compatible behavior, prometheusName() is called first to convert names to legacy Prometheus format before sanitization.

Changes:

  • Bump prometheusServerVersion from 1.3.10 to 1.5.0
  • Add prometheusName() calls for metric names and label names to preserve legacy escaping
  • Use stable Metrics class from io.prometheus.metrics.expositionformats.generated.Metrics instead of versioned protobuf package (new in 1.5.0, see Add stable Metrics class to decouple consumers from protobuf version prometheus/client_java#1873)
  • Add @SuppressWarnings("NonCanonicalType") — the stable Metrics class extends the versioned protobuf-generated class, so Error Prone flags inner type references as non-canonical

Test plan

  • All existing prometheus exporter tests pass (129 tests)
  • MetricReaderFactoryTest in sdk-extensions/incubator passes

@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.31%. Comparing base (297832a) to head (3815925).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8080      +/-   ##
============================================
- Coverage     90.31%   90.31%   -0.01%     
  Complexity     7606     7606              
============================================
  Files           839      839              
  Lines         22888    22889       +1     
  Branches       2283     2283              
============================================
  Hits          20672    20672              
  Misses         1506     1506              
- Partials        710      711       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

* strips invalid leading prefixes.
*/
private static String convertLabelName(String key) {
return sanitizeLabelName(prometheusName(key));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zeitlinger when I look into the code I see prometheusName calls escapeName(String, EscapingScheme), where EscapingScheme is an enum with values: ALLOW_UTF8, UNDERSCORE_ESCAPING, DOTS_ESCAPING, VALUE_ENCODING_ESCAPING

And I've seen some hints in the code that the metric and attribute name escaping is influenced by headers requested by the client. Do we need to escape at all or will prometheus do we want by default?

Also, we've had offline conversations about the prometheus client library automatically appending suffixes like _total and units, and not providing an opt out mechanism, which makes it problematic for us in opentelemetry-java to implement the translation strategy option. Want to confirm this is still the case with this new version. Seems a bit strange that prometheus would have facilities to produce a full unescaped utf8 metric name but still always produces metric names with the suffixes.

@zeitlinger zeitlinger force-pushed the update-prom-client-simple branch from 2b8cac6 to e56b562 Compare February 23, 2026 08:02
@zeitlinger zeitlinger changed the title Update Prometheus client to 1.4.3 Update Prometheus client to 1.5.0 Feb 23, 2026
@zeitlinger zeitlinger force-pushed the update-prom-client-simple branch from e56b562 to 63d2327 Compare February 23, 2026 08:18
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger zeitlinger force-pushed the update-prom-client-simple branch from 63d2327 to 3815925 Compare February 23, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants