diff --git a/CHANGELOG.md b/CHANGELOG.md index 06a9575ee0..7f9cb3376c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,9 @@ Increment the: * [SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.39.0 [#3813](https://github.com/open-telemetry/opentelemetry-cpp/pull/3813) +* [CONFIGURATION] File configuration - prometheus without_target_info + [#3818](https://github.com/open-telemetry/opentelemetry-cpp/pull/3818) + Breaking changes: * [CONFIGURATION] File configuration - remove zipkin diff --git a/exporters/prometheus/src/prometheus_pull_builder.cc b/exporters/prometheus/src/prometheus_pull_builder.cc index 245a30f38e..d81b324ee9 100644 --- a/exporters/prometheus/src/prometheus_pull_builder.cc +++ b/exporters/prometheus/src/prometheus_pull_builder.cc @@ -38,7 +38,7 @@ std::unique_ptr PrometheusPullBuilder url.append(std::to_string(model->port)); options.url = url; - options.populate_target_info = true; + options.populate_target_info = !model->without_target_info; options.without_otel_scope = model->without_scope_info; switch (model->translation_strategy) diff --git a/sdk/include/opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_configuration.h b/sdk/include/opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_configuration.h index 296e55d36e..c3aa03fe65 100644 --- a/sdk/include/opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_configuration.h +++ b/sdk/include/opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_configuration.h @@ -31,6 +31,7 @@ class PrometheusPullMetricExporterConfiguration : public PullMetricExporterConfi std::string host; std::size_t port{0}; bool without_scope_info{false}; + bool without_target_info{false}; std::unique_ptr with_resource_constant_labels; TranslationStrategy translation_strategy; }; diff --git a/sdk/src/configuration/configuration_parser.cc b/sdk/src/configuration/configuration_parser.cc index 97c8f0d0b9..c2f367cfe9 100644 --- a/sdk/src/configuration/configuration_parser.cc +++ b/sdk/src/configuration/configuration_parser.cc @@ -820,11 +820,10 @@ ConfigurationParser::ParsePrometheusPullMetricExporterConfiguration( auto model = std::make_unique(); std::unique_ptr child; - model->host = node->GetString("host", "localhost"); - model->port = node->GetInteger("port", 9464); - model->without_scope_info = node->GetBoolean("without_scope_info", false); - - // FIXME: without_target_info + model->host = node->GetString("host", "localhost"); + model->port = node->GetInteger("port", 9464); + model->without_scope_info = node->GetBoolean("without_scope_info", false); + model->without_target_info = node->GetBoolean("without_target_info", false); child = node->GetChildNode("with_resource_constant_labels"); if (child) diff --git a/sdk/test/configuration/yaml_metrics_test.cc b/sdk/test/configuration/yaml_metrics_test.cc index 1e398b2eef..f872be171c 100644 --- a/sdk/test/configuration/yaml_metrics_test.cc +++ b/sdk/test/configuration/yaml_metrics_test.cc @@ -540,6 +540,7 @@ file_format: "1.0-metrics" ASSERT_EQ(prometheus->host, "localhost"); ASSERT_EQ(prometheus->port, 9464); ASSERT_EQ(prometheus->without_scope_info, false); + ASSERT_EQ(prometheus->without_target_info, false); ASSERT_EQ(prometheus->translation_strategy, opentelemetry::sdk::configuration::TranslationStrategy::UnderscoreEscapingWithSuffixes); ASSERT_EQ(prometheus->with_resource_constant_labels, nullptr); @@ -557,6 +558,7 @@ file_format: "1.0-metrics" host: "prometheus" port: 1234 without_scope_info: true + without_target_info: true translation_strategy: NoUTF8EscapingWithSuffixes with_resource_constant_labels: included: @@ -582,6 +584,7 @@ file_format: "1.0-metrics" ASSERT_EQ(prometheus->host, "prometheus"); ASSERT_EQ(prometheus->port, 1234); ASSERT_EQ(prometheus->without_scope_info, true); + ASSERT_EQ(prometheus->without_target_info, true); ASSERT_EQ(prometheus->translation_strategy, opentelemetry::sdk::configuration::TranslationStrategy::NoUTF8EscapingWithSuffixes); ASSERT_NE(prometheus->with_resource_constant_labels, nullptr);