From ca620fb64cf8ecdd09a91c81d3198508358e460f Mon Sep 17 00:00:00 2001 From: Arthur Silva Sens Date: Thu, 7 Aug 2025 14:18:12 -0300 Subject: [PATCH 1/2] Add 'translation_strategy' to PrometheusMetricProducer Signed-off-by: Arthur Silva Sens --- examples/kitchen-sink.yaml | 11 +++++++++++ schema/meter_provider.json | 9 +++++++++ schema/type_descriptions.yaml | 13 +++++++++++++ 3 files changed, 33 insertions(+) diff --git a/examples/kitchen-sink.yaml b/examples/kitchen-sink.yaml index 3bb08f20..dc563508 100644 --- a/examples/kitchen-sink.yaml +++ b/examples/kitchen-sink.yaml @@ -202,9 +202,11 @@ meter_provider: port: 9464 # Configure Prometheus Exporter to produce metrics without a unit suffix or UNIT metadata. # If omitted or null, false is used. + # Deprecated: Use .translation_strategy instead. without_units: false # Configure Prometheus Exporter to produce metrics without a type suffix. # If omitted or null, false is used. + # Deprecated: Use .translation_strategy instead. without_type_suffix: false # Configure Prometheus Exporter to produce metrics without a scope info metric. # If omitted or null, false is used. @@ -225,6 +227,15 @@ meter_provider: # If omitted, .included resource attributes are included. excluded: - "service.attr1" + # Configure how Prometheus metrics are exposed. Values include: + # + # * UnderscoreEscapingWithSuffixes, the default. This fully escapes metric names for classic Prometheus metric name compatibility, and includes appending type and unit suffixes. + # * UnderscoreEscapingWithoutSuffixes, metric names will continue to escape special characters to _, but suffixes won't be attached. + # * NoUTF8EscapingWithSuffixes will disable changing special characters to _. Special suffixes like units and _total for counters will be attached. + # * NoTranslation. This strategy bypasses all metric and label name translation, passing them through unaltered. + # + # If omitted or null, UnderscoreEscapingWithSuffixes is used. + translation_strategy: UnderscoreEscapingWithSuffixes # Configure metric producers. producers: - # Configure metric producer to be opencensus. diff --git a/schema/meter_provider.json b/schema/meter_provider.json index bc1e9210..82848187 100644 --- a/schema/meter_provider.json +++ b/schema/meter_provider.json @@ -206,6 +206,15 @@ }, "with_resource_constant_labels": { "$ref": "common.json#/$defs/IncludeExclude" + }, + "translation_strategy": { + "type": ["string", "null"], + "enum": [ + "UnderscoreEscapingWithSuffixes", + "UnderscoreEscapingWithoutSuffixes", + "NoUTF8EscapingWithSuffixes", + "NoTranslation" + ] } } }, diff --git a/schema/type_descriptions.yaml b/schema/type_descriptions.yaml index b19e8edd..3fdfebc5 100644 --- a/schema/type_descriptions.yaml +++ b/schema/type_descriptions.yaml @@ -597,15 +597,28 @@ Configure Prometheus Exporter to produce metrics without a unit suffix or UNIT metadata. If omitted or null, false is used. + + Deprecated: Use .translation_strategy instead. without_type_suffix: > Configure Prometheus Exporter to produce metrics without a type suffix. If omitted or null, false is used. + + Deprecated: Use .translation_strategy instead. without_scope_info: > Configure Prometheus Exporter to produce metrics without a scope info metric. If omitted or null, false is used. with_resource_constant_labels: Configure Prometheus Exporter to add resource attributes as metrics attributes. + translation_strategy: > + Configure how Prometheus metrics are exposed. Values include: + + * UnderscoreEscapingWithSuffixes, the default. This fully escapes metric names for classic Prometheus metric name compatibility, and includes appending type and unit suffixes. + * UnderscoreEscapingWithoutSuffixes, metric names will continue to escape special characters to _, but suffixes won't be attached. + * NoUTF8EscapingWithSuffixes will disable changing special characters to _. Special suffixes like units and _total for counters will be attached. + * NoTranslation. This strategy bypasses all metric and label name translation, passing them through unaltered. + + If omitted or null, UnderscoreEscapingWithSuffixes is used. path_patterns: - .meter_provider.readers[].pull.exporter.prometheus/development - type: PrometheusIncludeExclude From 18b991a9468205b1053e04d1aadd1c6cdf501c2a Mon Sep 17 00:00:00 2001 From: Arthur Silva Sens Date: Tue, 12 Aug 2025 12:26:05 -0300 Subject: [PATCH 2/2] Document that translation strategy takes precedence over deprecated options Signed-off-by: Arthur Silva Sens --- examples/kitchen-sink.yaml | 4 ++-- schema/type_descriptions.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/kitchen-sink.yaml b/examples/kitchen-sink.yaml index dc563508..29711a40 100644 --- a/examples/kitchen-sink.yaml +++ b/examples/kitchen-sink.yaml @@ -202,11 +202,11 @@ meter_provider: port: 9464 # Configure Prometheus Exporter to produce metrics without a unit suffix or UNIT metadata. # If omitted or null, false is used. - # Deprecated: Use .translation_strategy instead. + # Deprecated: Use .translation_strategy instead. When both are set, .translation_strategy takes precedence. without_units: false # Configure Prometheus Exporter to produce metrics without a type suffix. # If omitted or null, false is used. - # Deprecated: Use .translation_strategy instead. + # Deprecated: Use .translation_strategy instead. When both are set, .translation_strategy takes precedence. without_type_suffix: false # Configure Prometheus Exporter to produce metrics without a scope info metric. # If omitted or null, false is used. diff --git a/schema/type_descriptions.yaml b/schema/type_descriptions.yaml index 3fdfebc5..7e545ec9 100644 --- a/schema/type_descriptions.yaml +++ b/schema/type_descriptions.yaml @@ -598,13 +598,13 @@ If omitted or null, false is used. - Deprecated: Use .translation_strategy instead. + Deprecated: Use .translation_strategy instead. When both are set, .translation_strategy takes precedence. without_type_suffix: > Configure Prometheus Exporter to produce metrics without a type suffix. If omitted or null, false is used. - Deprecated: Use .translation_strategy instead. + Deprecated: Use .translation_strategy instead. When both are set, .translation_strategy takes precedence. without_scope_info: > Configure Prometheus Exporter to produce metrics without a scope info metric.