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