From fe7eca763eb57ac88522e80d34cbfc0d40bcab98 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Wed, 13 Dec 2023 15:05:34 -0700 Subject: [PATCH] Add environment variable to disable Prometheus populate_target_info option --- exporters/prometheus/src/exporter_options.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/exporters/prometheus/src/exporter_options.cc b/exporters/prometheus/src/exporter_options.cc index fe07ad1bc5..5d6b17318a 100644 --- a/exporters/prometheus/src/exporter_options.cc +++ b/exporters/prometheus/src/exporter_options.cc @@ -36,8 +36,21 @@ inline bool GetPrometheusPopulateOtelScope() return exists ? setting : true; } +inline bool GetPrometheusPopulateTargetInfo() +{ + constexpr char kPrometheusPopulateTargetInfo[] = "PROMETHEUS_EXPORTER_POPULATE_TARGET_INFO"; + + bool setting; + auto exists = opentelemetry::sdk::common::GetBoolEnvironmentVariable( + kPrometheusPopulateTargetInfo, setting); + + return exists ? setting : true; +} + PrometheusExporterOptions::PrometheusExporterOptions() - : url(GetPrometheusDefaultHttpEndpoint()), populate_otel_scope(GetPrometheusPopulateOtelScope()) + : url(GetPrometheusDefaultHttpEndpoint()), + populate_target_info(GetPrometheusPopulateTargetInfo()), + populate_otel_scope(GetPrometheusPopulateOtelScope()) {} } // namespace metrics