Skip to content

Commit e9035a3

Browse files
authored
[CONFIGURATION] File configuration - prometheus without_target_info (open-telemetry#3818)
1 parent bde708e commit e9035a3

5 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Increment the:
3030
* [SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.39.0
3131
[#3813](https://github.com/open-telemetry/opentelemetry-cpp/pull/3813)
3232

33+
* [CONFIGURATION] File configuration - prometheus without_target_info
34+
[#3818](https://github.com/open-telemetry/opentelemetry-cpp/pull/3818)
35+
3336
Breaking changes:
3437

3538
* [CONFIGURATION] File configuration - remove zipkin

‎exporters/prometheus/src/prometheus_pull_builder.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ std::unique_ptr<opentelemetry::sdk::metrics::MetricReader> PrometheusPullBuilder
3838
url.append(std::to_string(model->port));
3939

4040
options.url = url;
41-
options.populate_target_info = true;
41+
options.populate_target_info = !model->without_target_info;
4242
options.without_otel_scope = model->without_scope_info;
4343

4444
switch (model->translation_strategy)

‎sdk/include/opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_configuration.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class PrometheusPullMetricExporterConfiguration : public PullMetricExporterConfi
3131
std::string host;
3232
std::size_t port{0};
3333
bool without_scope_info{false};
34+
bool without_target_info{false};
3435
std::unique_ptr<IncludeExcludeConfiguration> with_resource_constant_labels;
3536
TranslationStrategy translation_strategy;
3637
};

‎sdk/src/configuration/configuration_parser.cc‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -820,11 +820,10 @@ ConfigurationParser::ParsePrometheusPullMetricExporterConfiguration(
820820
auto model = std::make_unique<PrometheusPullMetricExporterConfiguration>();
821821
std::unique_ptr<DocumentNode> child;
822822

823-
model->host = node->GetString("host", "localhost");
824-
model->port = node->GetInteger("port", 9464);
825-
model->without_scope_info = node->GetBoolean("without_scope_info", false);
826-
827-
// FIXME: without_target_info
823+
model->host = node->GetString("host", "localhost");
824+
model->port = node->GetInteger("port", 9464);
825+
model->without_scope_info = node->GetBoolean("without_scope_info", false);
826+
model->without_target_info = node->GetBoolean("without_target_info", false);
828827

829828
child = node->GetChildNode("with_resource_constant_labels");
830829
if (child)

‎sdk/test/configuration/yaml_metrics_test.cc‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ file_format: "1.0-metrics"
540540
ASSERT_EQ(prometheus->host, "localhost");
541541
ASSERT_EQ(prometheus->port, 9464);
542542
ASSERT_EQ(prometheus->without_scope_info, false);
543+
ASSERT_EQ(prometheus->without_target_info, false);
543544
ASSERT_EQ(prometheus->translation_strategy,
544545
opentelemetry::sdk::configuration::TranslationStrategy::UnderscoreEscapingWithSuffixes);
545546
ASSERT_EQ(prometheus->with_resource_constant_labels, nullptr);
@@ -557,6 +558,7 @@ file_format: "1.0-metrics"
557558
host: "prometheus"
558559
port: 1234
559560
without_scope_info: true
561+
without_target_info: true
560562
translation_strategy: NoUTF8EscapingWithSuffixes
561563
with_resource_constant_labels:
562564
included:
@@ -582,6 +584,7 @@ file_format: "1.0-metrics"
582584
ASSERT_EQ(prometheus->host, "prometheus");
583585
ASSERT_EQ(prometheus->port, 1234);
584586
ASSERT_EQ(prometheus->without_scope_info, true);
587+
ASSERT_EQ(prometheus->without_target_info, true);
585588
ASSERT_EQ(prometheus->translation_strategy,
586589
opentelemetry::sdk::configuration::TranslationStrategy::NoUTF8EscapingWithSuffixes);
587590
ASSERT_NE(prometheus->with_resource_constant_labels, nullptr);

0 commit comments

Comments
 (0)