@@ -51,16 +51,16 @@ bool TemporalMetricStorage::buildMetrics(CollectorHandle *collector,
5151 AggregationTemporality aggregation_temporarily =
5252 collector->GetAggregationTemporality (instrument_descriptor_.type_ );
5353
54- // If no metrics, early return
55- if (delta_metrics->Size () == 0 )
56- {
57- return true ;
58- }
59-
6054 // Fast path for single collector with delta temporality and counter, updown-counter, histogram
55+ // This path doesn't need to aggregated-with/contribute-to the unreported_metric_, as there is
56+ // no other reader configured to collect those data.
6157 if (collectors.size () == 1 && aggregation_temporarily == AggregationTemporality::kDelta )
6258 {
63-
59+ // If no metrics, early return
60+ if (delta_metrics->Size () == 0 )
61+ {
62+ return true ;
63+ }
6464 // Create MetricData directly
6565 MetricData metric_data;
6666 metric_data.instrument_descriptor = instrument_descriptor_;
@@ -77,12 +77,10 @@ bool TemporalMetricStorage::buildMetrics(CollectorHandle *collector,
7777 metric_data.point_data_attr_ .emplace_back (std::move (point_data_attr));
7878 return true ;
7979 });
80-
8180 return callback (metric_data);
8281 }
8382
84- if (delta_metrics->Size ())
85- {
83+ if (delta_metrics->Size ()) {
8684 for (auto &col : collectors)
8785 {
8886 unreported_metrics_[col.get ()].push_back (delta_metrics);
0 commit comments