diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py index ea48aa70239..ae21db907dd 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py @@ -288,13 +288,11 @@ def collect( """ Atomically return a point for the current value of the metric. """ - with self._lock: + if not any(self._bucket_counts): + return None - bucket_counts = [ - bucket_count for bucket_count in self._bucket_counts - ] - + bucket_counts = self._bucket_counts start_time_unix_nano = self._start_time_unix_nano sum_ = self._sum max_ = self._max