From 00b0b6673a047ead45f9b19befe62553fdb1ba1e Mon Sep 17 00:00:00 2001 From: owent Date: Tue, 19 Sep 2023 23:56:07 +0800 Subject: [PATCH] Fix warnings --- exporters/prometheus/src/collector.cc | 3 ++- exporters/prometheus/src/exporter_utils.cc | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/exporters/prometheus/src/collector.cc b/exporters/prometheus/src/collector.cc index 3dde2beaee..b066f3eb7b 100644 --- a/exporters/prometheus/src/collector.cc +++ b/exporters/prometheus/src/collector.cc @@ -50,7 +50,8 @@ std::vector PrometheusCollector::Collect() cons } reader_->Collect([&result, populate_target_info](sdk::metrics::ResourceMetrics &metric_data) { - auto prometheus_metric_data = PrometheusExporterUtils::TranslateToPrometheus(metric_data); + auto prometheus_metric_data = + PrometheusExporterUtils::TranslateToPrometheus(metric_data, populate_target_info); for (auto &data : prometheus_metric_data) result.emplace_back(data); return true; diff --git a/exporters/prometheus/src/exporter_utils.cc b/exporters/prometheus/src/exporter_utils.cc index 997374be85..e8ef83aca9 100644 --- a/exporters/prometheus/src/exporter_utils.cc +++ b/exporters/prometheus/src/exporter_utils.cc @@ -1,6 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#include #include #include #include @@ -94,7 +95,7 @@ std::vector PrometheusExporterUtils::TranslateT } else { - sum = nostd::get(histogram_point_data.sum_); + sum = static_cast(nostd::get(histogram_point_data.sum_)); } SetData(std::vector{sum, (double)histogram_point_data.count_}, boundaries, counts, point_data_attr.attributes, time, &metric_family, data.resource_); @@ -518,7 +519,7 @@ void PrometheusExporterUtils::SetValue(std::vector values, const auto &value_var = values[0]; if (nostd::holds_alternative(value_var)) { - value = nostd::get(value_var); + value = static_cast(nostd::get(value_var)); } else { @@ -553,9 +554,9 @@ void PrometheusExporterUtils::SetValue(std::vector values, const std::vector &counts, prometheus_client::ClientMetric *metric) { - metric->histogram.sample_sum = values[0]; - metric->histogram.sample_count = values[1]; - int cumulative = 0; + metric->histogram.sample_sum = static_cast(values[0]); + metric->histogram.sample_count = static_cast(values[1]); + std::uint64_t cumulative = 0; std::vector buckets; uint32_t idx = 0; for (const auto &boundary : boundaries)