Summary
Implement the translation_strategy configuration option for the Prometheus exporter.
This controls how OTel metric/label names are translated to Prometheus format and whether type/unit suffixes are appended. The converter becomes the single authority for suffix decisions — the OM2 format writer renders names as-is (no smart-append).
Strategies
| Strategy |
Escaping |
expositionBaseName |
Labels |
__ collapse |
UnderscoreEscapingWithSuffixes (default) |
prometheusName() |
base + unit + type suffix (_total, _info) |
prometheusName() |
yes |
UnderscoreEscapingWithoutSuffixes |
prometheusName() |
base only |
prometheusName() |
yes |
NoUTF8EscapingWithSuffixes |
passthrough |
base + unit + type suffix |
passthrough |
no |
NoTranslation |
passthrough |
raw OTel name (via originalName) |
passthrough |
no |
Key design decision: the converter uses the 4-arg MetricMetadata(name, expositionBaseName, help, unit) constructor to explicitly control what the OM2 writer outputs. sanitizeMetricName() is no longer called (it's a no-op in prom_client_java 1.6+).
Changes required
Otel2PrometheusConverter — branch convertMetadata() and convertLabelName() on strategy. Type-aware suffix logic (append _total for counters, _info for info metrics) moves into the converter.
PrometheusMetricReaderBuilder — add setTranslationStrategy(TranslationStrategy)
PrometheusHttpServerBuilder — delegate to reader builder
PrometheusComponentProvider (DC) — wire translation_strategy from config model (enum already exists in generated schema)
- No env var / system property — DC only, per spec
Dependencies
The NoUTF8EscapingWithSuffixes and NoTranslation strategies depend on prometheus/client_java scrape-time-suffix-handling branch which adds originalName, expositionBaseName, and scrape-time suffix handling. The implementation PR will be a draft until the next prom_client_java release includes these changes.
Previous work
- #7588 — earlier attempt with a
utf8 flag, closed in favor of translation_strategy
- #8080 — updated prom client to 1.5.0 with backward-compatible escaping
Summary
Implement the
translation_strategyconfiguration option for the Prometheus exporter.This controls how OTel metric/label names are translated to Prometheus format and whether type/unit suffixes are appended. The converter becomes the single authority for suffix decisions — the OM2 format writer renders names as-is (no smart-append).
Strategies
expositionBaseName__collapseUnderscoreEscapingWithSuffixes(default)prometheusName()_total,_info)prometheusName()UnderscoreEscapingWithoutSuffixesprometheusName()prometheusName()NoUTF8EscapingWithSuffixesNoTranslationoriginalName)Key design decision: the converter uses the 4-arg
MetricMetadata(name, expositionBaseName, help, unit)constructor to explicitly control what the OM2 writer outputs.sanitizeMetricName()is no longer called (it's a no-op in prom_client_java 1.6+).Changes required
Otel2PrometheusConverter— branchconvertMetadata()andconvertLabelName()on strategy. Type-aware suffix logic (append_totalfor counters,_infofor info metrics) moves into the converter.PrometheusMetricReaderBuilder— addsetTranslationStrategy(TranslationStrategy)PrometheusHttpServerBuilder— delegate to reader builderPrometheusComponentProvider(DC) — wiretranslation_strategyfrom config model (enum already exists in generated schema)Dependencies
The
NoUTF8EscapingWithSuffixesandNoTranslationstrategies depend on prometheus/client_javascrape-time-suffix-handlingbranch which addsoriginalName,expositionBaseName, and scrape-time suffix handling. The implementation PR will be a draft until the next prom_client_java release includes these changes.Previous work
utf8flag, closed in favor oftranslation_strategy