@@ -51,6 +51,36 @@ bool TemporalMetricStorage::buildMetrics(CollectorHandle *collector,
5151 AggregationTemporality aggregation_temporarily =
5252 collector->GetAggregationTemporality (instrument_descriptor_.type_ );
5353
54+ // Fast path for single collector with delta temporality and counter, updown-counter, histogram
55+ if (collectors.size () == 1 && collector->GetAggregationTemporality (
56+ instrument_descriptor_.type_ ) == AggregationTemporality::kDelta )
57+ {
58+ // If no metrics, early return
59+ if (delta_metrics->Size () == 0 )
60+ {
61+ return true ;
62+ }
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+
81+ return callback (metric_data);
82+ }
83+
5484 if (delta_metrics->Size ())
5585 {
5686 for (auto &col : collectors)
0 commit comments