Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed Sep 19, 2023
1 parent 72ed751 commit 00b0b66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion exporters/prometheus/src/collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ std::vector<prometheus_client::MetricFamily> 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;
Expand Down
11 changes: 6 additions & 5 deletions exporters/prometheus/src/exporter_utils.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#include <limits>
#include <sstream>
#include <string>
#include <unordered_map>
Expand Down Expand Up @@ -94,7 +95,7 @@ std::vector<prometheus_client::MetricFamily> PrometheusExporterUtils::TranslateT
}
else
{
sum = nostd::get<int64_t>(histogram_point_data.sum_);
sum = static_cast<double>(nostd::get<int64_t>(histogram_point_data.sum_));
}
SetData(std::vector<double>{sum, (double)histogram_point_data.count_}, boundaries, counts,
point_data_attr.attributes, time, &metric_family, data.resource_);
Expand Down Expand Up @@ -518,7 +519,7 @@ void PrometheusExporterUtils::SetValue(std::vector<T> values,
const auto &value_var = values[0];
if (nostd::holds_alternative<int64_t>(value_var))
{
value = nostd::get<int64_t>(value_var);
value = static_cast<double>(nostd::get<int64_t>(value_var));
}
else
{
Expand Down Expand Up @@ -553,9 +554,9 @@ void PrometheusExporterUtils::SetValue(std::vector<T> values,
const std::vector<uint64_t> &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<double>(values[0]);
metric->histogram.sample_count = static_cast<std::uint64_t>(values[1]);
std::uint64_t cumulative = 0;
std::vector<prometheus_client::ClientMetric::Bucket> buckets;
uint32_t idx = 0;
for (const auto &boundary : boundaries)
Expand Down

0 comments on commit 00b0b66

Please sign in to comment.