From a0b322bf0fce6597b80eab7e3a983c080b1fc269 Mon Sep 17 00:00:00 2001 From: owent Date: Fri, 22 Sep 2023 00:06:30 +0800 Subject: [PATCH] Do not ignore metric attributes. --- .../exporters/prometheus/exporter_utils.h | 9 --------- exporters/prometheus/src/exporter_utils.cc | 18 ------------------ 2 files changed, 27 deletions(-) diff --git a/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h b/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h index ff2fc9faa9..6a4163f740 100644 --- a/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h +++ b/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h @@ -63,15 +63,6 @@ class PrometheusExporterUtils */ static bool ShouldIgnoreResourceAttribute(const std::string &name); - /** - * Some attributes should be ignored when converting metric attributes to - * prometheus labels. - * - * @param name attribute name - * @return true if the attribute should be ignored, false otherwise. - */ - static bool ShouldIgnoreMetricAttribute(const std::string &name); - static opentelemetry::sdk::metrics::AggregationType getAggregationType( const opentelemetry::sdk::metrics::PointType &point_type); diff --git a/exporters/prometheus/src/exporter_utils.cc b/exporters/prometheus/src/exporter_utils.cc index bb84f0c4c4..53cdeca9f4 100644 --- a/exporters/prometheus/src/exporter_utils.cc +++ b/exporters/prometheus/src/exporter_utils.cc @@ -214,19 +214,6 @@ bool PrometheusExporterUtils::ShouldIgnoreResourceAttribute(const std::string &n return ignores.end() != ignores.find(name); } -bool PrometheusExporterUtils::ShouldIgnoreMetricAttribute(const std::string &name) -{ - static std::unordered_set ignores{ - opentelemetry::sdk::resource::SemanticConventions::kServiceName, - opentelemetry::sdk::resource::SemanticConventions::kServiceInstanceId, - opentelemetry::trace::SemanticConventions::kServerAddress, - opentelemetry::trace::SemanticConventions::kServerPort, - opentelemetry::trace::SemanticConventions::kUrlScheme, - kPrometheusJob, - kPrometheusInstance}; - return ignores.end() != ignores.find(name); -} - metric_sdk::AggregationType PrometheusExporterUtils::getAggregationType( const metric_sdk::PointType &point_type) { @@ -390,11 +377,6 @@ void PrometheusExporterUtils::SetMetricBasic(prometheus_client::ClientMetric &me { for (auto &label : labels) { - if (ShouldIgnoreMetricAttribute(label.first)) - { - continue; - } - std::string label_name = SanitizeNames(label.first); if (label_name == kPrometheusInstance) {