diff --git a/exporters/prometheus/src/collector.cc b/exporters/prometheus/src/collector.cc index 9082f49f6f..33b9a9b8c8 100644 --- a/exporters/prometheus/src/collector.cc +++ b/exporters/prometheus/src/collector.cc @@ -40,10 +40,9 @@ std::vector PrometheusCollector::Collect() cons std::vector result; - bool populate_target_info = populate_target_info_; - reader_->Collect([&result, populate_target_info](sdk::metrics::ResourceMetrics &metric_data) { + reader_->Collect([&result, this](sdk::metrics::ResourceMetrics &metric_data) { auto prometheus_metric_data = - PrometheusExporterUtils::TranslateToPrometheus(metric_data, populate_target_info); + PrometheusExporterUtils::TranslateToPrometheus(metric_data, this->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 5b834f8176..0ecabc3983 100644 --- a/exporters/prometheus/src/exporter_utils.cc +++ b/exporters/prometheus/src/exporter_utils.cc @@ -379,7 +379,7 @@ void PrometheusExporterUtils::SetMetricBasic( // Note that attribute keys are sorted, but sanitized keys can be out-of-order. // We could sort the sanitized keys again, but this seems too expensive to do // in this hot code path. Instead, we ignore out-of-order keys and emit a warning. - metric.label.reserve(labels.size() + 2); + metric.label.reserve(labels.size()); std::string previous_key; for (auto const &label : labels) {