Skip to content

Commit 29f93c5

Browse files
committed
reduce allocs
1 parent 63f2471 commit 29f93c5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/AsynchronousMetricStorage.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ private Collection<T> collectWithDeltaAggregationTemporality() {
247247
List<T> deltaPoints = memoryMode == REUSABLE_DATA ? reusablePointsList : new ArrayList<>();
248248
currentPoints.forEach(
249249
(attributes, currentPoint) -> {
250-
T lastPoint = lastPoints.get(attributes);
250+
T lastPoint = lastPoints.remove(attributes);
251251

252252
T deltaPoint;
253253
if (lastPoint == null) {
@@ -272,9 +272,9 @@ private Collection<T> collectWithDeltaAggregationTemporality() {
272272
});
273273

274274
if (memoryMode == REUSABLE_DATA) {
275-
// lastPoints for the current collection can be discarded when the collection is completed.
276-
// They can be returned to the pool because they're not managed by the AggregatorHandle,
277-
// we made a copy.
275+
// - If the point was used to compute a delta, it's now in deltaPoints (and thus in
276+
// reusablePointsList)
277+
// - If the point hasn't been used, it's still in lastPoints and can be returned
278278
lastPoints.forEach(pointReleaser);
279279
lastPoints.clear();
280280

0 commit comments

Comments
 (0)