From 0149d5ccdfe3c83812e2edaaa6350c5463da8c4b Mon Sep 17 00:00:00 2001 From: owent Date: Tue, 3 Oct 2023 23:27:38 +0800 Subject: [PATCH] Restore `+2` when reserve space for vector. Signed-off-by: owent --- exporters/prometheus/src/exporter_utils.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/prometheus/src/exporter_utils.cc b/exporters/prometheus/src/exporter_utils.cc index 49ece800a5..42fafc6336 100644 --- a/exporters/prometheus/src/exporter_utils.cc +++ b/exporters/prometheus/src/exporter_utils.cc @@ -381,7 +381,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()); + metric.label.reserve(labels.size() + 2); std::string previous_key; for (auto const &label : labels) {