From 53ae9ae902d800d4764368e8fea6009e0797443c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauricio=20V=C3=A1squez?= Date: Tue, 25 Feb 2020 07:42:41 -0500 Subject: [PATCH] add locks on merge() too --- .../src/opentelemetry/sdk/metrics/export/aggregate.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/aggregate.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/aggregate.py index 9e707469f8d..f082cce8919 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/aggregate.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/aggregate.py @@ -60,7 +60,8 @@ def take_checkpoint(self): self.current = 0 def merge(self, other): - self.checkpoint += other.checkpoint + with self._lock: + self.checkpoint += other.checkpoint class MinMaxSumCountAggregator(Aggregator): @@ -106,6 +107,7 @@ def take_checkpoint(self): self.current = self._EMPTY def merge(self, other): - self.checkpoint = self._merge_checkpoint( - self.checkpoint, other.checkpoint - ) + with self._lock: + self.checkpoint = self._merge_checkpoint( + self.checkpoint, other.checkpoint + )