Skip to content

Commit f6e4818

Browse files
authored
[CONFIGURATION] Update prometheus config to schema v1.1.0 (#4383)
1 parent 7532fca commit f6e4818

11 files changed

Lines changed: 37 additions & 32 deletions

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ Breaking changes:
183183
* The public configuration member `max_buckets_` was renamed to `max_size_` to
184184
match the configuration schema. Please adjust SDK configuration accordingly.
185185

186+
* [CONFIGURATION] Update prometheus config to schema v1.1.0
187+
[#4383](https://github.com/open-telemetry/opentelemetry-cpp/pull/4383)
188+
* The following YAML values for `translation_strategy` have been replaced
189+
* `UnderscoreEscapingWithSuffixes` is replaced by `underscore_escaping_with_suffixes`
190+
* `UnderscoreEscapingWithoutSuffixes` is replaced by `underscore_escaping_without_suffixes/development`
191+
* `NoUTF8EscapingWithSuffixes` is replaced by `no_utf8_escaping_with_suffixes/development`
192+
* `NoTranslation` is replaced by `no_translation/development`
193+
186194
## [1.28.0] 2026-07-16
187195

188196
* [RELEASE] Bump main branch to 1.28.0-dev

‎examples/configuration/kitchen-sink.yaml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ meter_provider:
250250
# If omitted, .included resource attributes are included.
251251
excluded:
252252
- "service.attr1"
253+
# Configure how metric names are translated to Prometheus metric names.
254+
# If omitted or null, underscore_escaping_with_suffixes is used.
255+
# Values include: underscore_escaping_with_suffixes, underscore_escaping_without_suffixes/development, no_utf8_escaping_with_suffixes/development, no_translation/development
256+
translation_strategy: underscore_escaping_with_suffixes
253257
# Configure metric producers.
254258
producers:
255259
- # Configure metric producer to be opencensus.
@@ -344,10 +348,6 @@ meter_provider:
344348
# Values include: explicit_bucket_histogram, base2_exponential_bucket_histogram. For behavior of values, see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk_exporters/otlp.md.
345349
# If omitted or null, explicit_bucket_histogram is used.
346350
default_histogram_aggregation: base2_exponential_bucket_histogram
347-
# Configure metric producers.
348-
producers:
349-
- # Configure metric producer to be prometheus.
350-
prometheus:
351351
# Configure cardinality limits.
352352
cardinality_limits:
353353
# Configure default cardinality limit for all instrument types.

‎exporters/prometheus/src/prometheus_pull_builder.cc‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ std::unique_ptr<opentelemetry::sdk::metrics::MetricReader> PrometheusPullBuilder
5353
break;
5454
case sdk::configuration::TranslationStrategy::NoUTF8EscapingWithSuffixes:
5555
// FIXME: no flag to disable UnderscoreEscaping
56-
OTEL_INTERNAL_LOG_WARN("[Prometheus Exporter] NoUTF8EscapingWithSuffixes not supported");
56+
OTEL_INTERNAL_LOG_WARN(
57+
"[Prometheus Exporter] no_utf8_escaping_with_suffixes/development not supported");
5758
options.without_units = false;
5859
options.without_type_suffix = false;
5960
break;
6061
case sdk::configuration::TranslationStrategy::NoTranslation:
6162
// FIXME: no flag to disable UnderscoreEscaping
62-
OTEL_INTERNAL_LOG_WARN("[Prometheus Exporter] NoTranslation not supported");
63+
OTEL_INTERNAL_LOG_WARN("[Prometheus Exporter] no_translation/development not supported");
6364
options.without_units = true;
6465
options.without_type_suffix = true;
6566
break;

‎functional/configuration/shelltests/prometheus_translation_no.test‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
$ example_yaml --test --yaml shelltests/prometheus_translation_no.yaml
55
>
66
MODEL PARSED
7-
[WARNING] [Prometheus Exporter] NoTranslation not supported
7+
[WARNING] [Prometheus Exporter] no_translation/development not supported
88
[WARNING] [Prometheus Exporter] resource_constant_labels not supported
99
SDK CREATED
1010
>= 0
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Copyright The OpenTelemetry Authors
22
# SPDX-License-Identifier: Apache-2.0
3-
# SKIP_SCHEMA_VALIDATION: translation_strategy 'NoTranslation' renamed to 'no_translation/development' in schema v1.0; C++ parser not yet updated
43

5-
file_format: "1.0"
4+
file_format: "1.1"
65

76
meter_provider:
87
readers:
@@ -11,8 +10,8 @@ meter_provider:
1110
prometheus/development:
1211
host: localhost
1312
port: 9464
14-
without_scope_info: false
15-
translation_strategy: NoTranslation
16-
with_resource_constant_labels:
13+
scope_info_enabled: true
14+
translation_strategy: no_translation/development
15+
resource_constant_labels:
1716
included:
1817
- "not supported"

‎functional/configuration/shelltests/prometheus_translation_no_utf8.test‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
$ example_yaml --test --yaml shelltests/prometheus_translation_no_utf8.yaml
55
>
66
MODEL PARSED
7-
[WARNING] [Prometheus Exporter] NoUTF8EscapingWithSuffixes not supported
7+
[WARNING] [Prometheus Exporter] no_utf8_escaping_with_suffixes/development not supported
88
SDK CREATED
99
>= 0
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Copyright The OpenTelemetry Authors
22
# SPDX-License-Identifier: Apache-2.0
3-
# SKIP_SCHEMA_VALIDATION: translation_strategy 'NoUTF8EscapingWithSuffixes' renamed to 'no_utf8_escaping_with_suffixes/development' in schema v1.0; C++ parser not yet updated
43

5-
file_format: "1.0"
4+
file_format: "1.1"
65

76
meter_provider:
87
readers:
@@ -11,5 +10,5 @@ meter_provider:
1110
prometheus/development:
1211
host: localhost
1312
port: 9464
14-
without_scope_info: false
15-
translation_strategy: NoUTF8EscapingWithSuffixes
13+
scope_info_enabled: true
14+
translation_strategy: no_utf8_escaping_with_suffixes/development
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Copyright The OpenTelemetry Authors
22
# SPDX-License-Identifier: Apache-2.0
3-
# SKIP_SCHEMA_VALIDATION: translation_strategy 'UnderscoreEscapingWithSuffixes' renamed to 'underscore_escaping_with_suffixes' in schema v1.0; C++ parser not yet updated
43

5-
file_format: "1.0"
4+
file_format: "1.1"
65

76
meter_provider:
87
readers:
@@ -11,5 +10,5 @@ meter_provider:
1110
prometheus/development:
1211
host: localhost
1312
port: 9464
14-
without_scope_info: false
15-
translation_strategy: UnderscoreEscapingWithSuffixes
13+
scope_info_enabled: true
14+
translation_strategy: underscore_escaping_with_suffixes
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Copyright The OpenTelemetry Authors
22
# SPDX-License-Identifier: Apache-2.0
3-
# SKIP_SCHEMA_VALIDATION: translation_strategy 'UnderscoreEscapingWithoutSuffixes' renamed to 'underscore_escaping_without_suffixes/development' in schema v1.0; C++ parser not yet updated
43

5-
file_format: "1.0"
4+
file_format: "1.1"
65

76
meter_provider:
87
readers:
@@ -11,5 +10,5 @@ meter_provider:
1110
prometheus/development:
1211
host: localhost
1312
port: 9464
14-
without_scope_info: false
15-
translation_strategy: UnderscoreEscapingWithoutSuffixes
13+
scope_info_enabled: true
14+
translation_strategy: underscore_escaping_without_suffixes/development

‎sdk/src/configuration/configuration_parser.cc‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -898,22 +898,22 @@ TranslationStrategy ConfigurationParser::ParseTranslationStrategy(
898898
const std::unique_ptr<DocumentNode> &node,
899899
const std::string &name) const
900900
{
901-
if (name == "UnderscoreEscapingWithSuffixes")
901+
if (name == "underscore_escaping_with_suffixes")
902902
{
903903
return TranslationStrategy::UnderscoreEscapingWithSuffixes;
904904
}
905905

906-
if (name == "UnderscoreEscapingWithoutSuffixes")
906+
if (name == "underscore_escaping_without_suffixes/development")
907907
{
908908
return TranslationStrategy::UnderscoreEscapingWithoutSuffixes;
909909
}
910910

911-
if (name == "NoUTF8EscapingWithSuffixes")
911+
if (name == "no_utf8_escaping_with_suffixes/development")
912912
{
913913
return TranslationStrategy::NoUTF8EscapingWithSuffixes;
914914
}
915915

916-
if (name == "NoTranslation")
916+
if (name == "no_translation/development")
917917
{
918918
return TranslationStrategy::NoTranslation;
919919
}
@@ -965,7 +965,7 @@ ConfigurationParser::ParsePrometheusPullMetricExporterConfiguration(
965965
}
966966

967967
std::string translation_strategy =
968-
node->GetString("translation_strategy", "UnderscoreEscapingWithSuffixes");
968+
node->GetString("translation_strategy", "underscore_escaping_with_suffixes");
969969
model->translation_strategy = ParseTranslationStrategy(node, translation_strategy);
970970

971971
return model;

0 commit comments

Comments
 (0)