@@ -51,6 +51,35 @@ bool TemporalMetricStorage::buildMetrics(CollectorHandle *collector,
51
51
AggregationTemporality aggregation_temporarily =
52
52
collector->GetAggregationTemporality (instrument_descriptor_.type_ );
53
53
54
+ // 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.
57
+ if (collectors.size () == 1 && aggregation_temporarily == AggregationTemporality::kDelta )
58
+ {
59
+ // If no metrics, early return
60
+ if (delta_metrics->Size () == 0 )
61
+ {
62
+ return true ;
63
+ }
64
+ // Create MetricData directly
65
+ MetricData metric_data;
66
+ metric_data.instrument_descriptor = instrument_descriptor_;
67
+ metric_data.aggregation_temporality = AggregationTemporality::kDelta ;
68
+ metric_data.start_ts = sdk_start_ts;
69
+ metric_data.end_ts = collection_ts;
70
+
71
+ // Direct conversion of delta metrics to point data
72
+ delta_metrics->GetAllEnteries (
73
+ [&metric_data](const MetricAttributes &attributes, Aggregation &aggregation) {
74
+ PointDataAttributes point_data_attr;
75
+ point_data_attr.point_data = aggregation.ToPoint ();
76
+ point_data_attr.attributes = attributes;
77
+ metric_data.point_data_attr_ .emplace_back (std::move (point_data_attr));
78
+ return true ;
79
+ });
80
+ return callback (metric_data);
81
+ }
82
+
54
83
if (delta_metrics->Size ())
55
84
{
56
85
for (auto &col : collectors)
0 commit comments