opentelemetry-java icon indicating copy to clipboard operation
opentelemetry-java copied to clipboard

Update prom client with support for UTF-8

Open zeitlinger opened this issue 4 months ago • 4 comments

To avoid a breaking change

  • a new flag has been introduced to opt-in to UTF-8 support: otel.exporter.prometheus.utf8 -> this is wrong
  • we should use translation_strategy instead
    • see https://github.com/open-telemetry/opentelemetry-specification/issues/4634
    • requires https://github.com/prometheus/client_java/pull/1557

zeitlinger avatar Aug 18 '25 17:08 zeitlinger

Codecov Report

:x: Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review. :white_check_mark: Project coverage is 89.98%. Comparing base (63d4617) to head (4c214e3). :warning: Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ry/exporter/prometheus/PrometheusMetricReader.java 66.66% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7588      +/-   ##
============================================
- Coverage     89.99%   89.98%   -0.01%     
- Complexity     7079     7081       +2     
============================================
  Files           803      803              
  Lines         21412    21428      +16     
  Branches       2086     2087       +1     
============================================
+ Hits          19269    19282      +13     
- Misses         1479     1482       +3     
  Partials        664      664              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov[bot] avatar Aug 27 '25 15:08 codecov[bot]

@jkwatson please have a look

zeitlinger avatar Sep 01 '25 10:09 zeitlinger

no longer blocked by the spec?

jkwatson avatar Sep 01 '25 15:09 jkwatson

no longer blocked by the spec?

We talked in the spec meeting that it's up to the SDKs to decide if __ should be converted to _ or not.

So from that point of view, we're free to keep __ as is. However, I didn't want to introduce a breaking change (which is also SDK decision) - so I added a setting to enable UTF-8.

If

  • otel.exporter.prometheus.utf8 is false, we shorten __ to _ (and %% becomes __ and then _)
  • otel.exporter.prometheus.utf8 is true, the SDK passes all chars as is to the prom client - expecting that the user wants to keep that as is in the entire pipeline

We can decide that we're OK with the breaking change - and then we don't need this property.

zeitlinger avatar Sep 01 '25 15:09 zeitlinger