diff --git a/CHANGELOG.md b/CHANGELOG.md index f09553ce70..5b2e80326e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ Increment the: * [DEPRECATION] Deprecate ZPAGES [#2291](https://github.com/open-telemetry/opentelemetry-cpp/pull/2291) +* [EXPORTER] Remove explicit timestamps from metric points exported by Prometheus + [#2324](https://github.com/open-telemetry/opentelemetry-cpp/pull/2324) ## [1.11.0] 2023-08-21 diff --git a/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h b/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h index ce7f0a1191..cb7da0b2b5 100644 --- a/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h +++ b/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h @@ -58,7 +58,6 @@ class PrometheusExporterUtils static void SetData(std::vector values, const opentelemetry::sdk::metrics::PointAttributes &labels, ::prometheus::MetricType type, - std::chrono::nanoseconds time, ::prometheus::MetricFamily *metric_family); /** @@ -70,14 +69,12 @@ class PrometheusExporterUtils const std::vector &boundaries, const std::vector &counts, const opentelemetry::sdk::metrics::PointAttributes &labels, - std::chrono::nanoseconds time, ::prometheus::MetricFamily *metric_family); /** * Set time and labels to metric data */ static void SetMetricBasic(::prometheus::ClientMetric &metric, - std::chrono::nanoseconds time, const opentelemetry::sdk::metrics::PointAttributes &labels); /** diff --git a/exporters/prometheus/src/exporter_utils.cc b/exporters/prometheus/src/exporter_utils.cc index 966d665df6..6a71ee79b7 100644 --- a/exporters/prometheus/src/exporter_utils.cc +++ b/exporters/prometheus/src/exporter_utils.cc @@ -72,7 +72,7 @@ std::vector PrometheusExporterUtils::TranslateT sum = nostd::get(histogram_point_data.sum_); } SetData(std::vector{sum, (double)histogram_point_data.count_}, boundaries, counts, - point_data_attr.attributes, time, &metric_family); + point_data_attr.attributes, &metric_family); } else if (type == prometheus_client::MetricType::Gauge) { @@ -82,14 +82,14 @@ std::vector PrometheusExporterUtils::TranslateT auto last_value_point_data = nostd::get(point_data_attr.point_data); std::vector values{last_value_point_data.value_}; - SetData(values, point_data_attr.attributes, type, time, &metric_family); + SetData(values, point_data_attr.attributes, type, &metric_family); } else if (nostd::holds_alternative(point_data_attr.point_data)) { auto sum_point_data = nostd::get(point_data_attr.point_data); std::vector values{sum_point_data.value_}; - SetData(values, point_data_attr.attributes, type, time, &metric_family); + SetData(values, point_data_attr.attributes, type, &metric_family); } else { @@ -105,7 +105,7 @@ std::vector PrometheusExporterUtils::TranslateT auto sum_point_data = nostd::get(point_data_attr.point_data); std::vector values{sum_point_data.value_}; - SetData(values, point_data_attr.attributes, type, time, &metric_family); + SetData(values, point_data_attr.attributes, type, &metric_family); } else { @@ -228,12 +228,11 @@ template void PrometheusExporterUtils::SetData(std::vector values, const metric_sdk::PointAttributes &labels, prometheus_client::MetricType type, - std::chrono::nanoseconds time, prometheus_client::MetricFamily *metric_family) { metric_family->metric.emplace_back(); prometheus_client::ClientMetric &metric = metric_family->metric.back(); - SetMetricBasic(metric, time, labels); + SetMetricBasic(metric, labels); SetValue(values, type, &metric); } @@ -246,24 +245,20 @@ void PrometheusExporterUtils::SetData(std::vector values, const std::vector &boundaries, const std::vector &counts, const metric_sdk::PointAttributes &labels, - std::chrono::nanoseconds time, prometheus_client::MetricFamily *metric_family) { metric_family->metric.emplace_back(); prometheus_client::ClientMetric &metric = metric_family->metric.back(); - SetMetricBasic(metric, time, labels); + SetMetricBasic(metric, labels); SetValue(values, boundaries, counts, &metric); } /** - * Set time and labels to metric data + * Set labels to metric data */ void PrometheusExporterUtils::SetMetricBasic(prometheus_client::ClientMetric &metric, - std::chrono::nanoseconds time, const metric_sdk::PointAttributes &labels) { - metric.timestamp_ms = time.count() / 1000000; - // auto label_pairs = ParseLabel(labels); if (!labels.empty()) {