Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#2525](https://github.com/open-telemetry/opentelemetry-python/pull/2525))
- Change OTLPHandler to LoggingHandler
([#2528](https://github.com/open-telemetry/opentelemetry-python/pull/2528))
- Fix delta histogram sum not being reset on collection
([#2533](https://github.com/open-telemetry/opentelemetry-python/pull/2533))

## [1.10.0-0.29b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.10.0-0.29b0) - 2022-03-10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,19 @@ def collect(self) -> Histogram:
with self._lock:
value = self._bucket_counts
start_time_unix_nano = self._start_time_unix_nano
histogram_sum = self._sum

self._bucket_counts = self._get_empty_bucket_counts()
self._start_time_unix_nano = now + 1
self._sum = 0

return Histogram(
start_time_unix_nano=start_time_unix_nano,
time_unix_nano=now,
bucket_counts=tuple(value),
explicit_bounds=self._boundaries,
aggregation_temporality=AggregationTemporality.DELTA,
sum=self._sum,
sum=histogram_sum,
)


Expand Down
2 changes: 2 additions & 0 deletions opentelemetry-sdk/tests/metrics/test_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def test_collect(self):
first_histogram = explicit_bucket_histogram_aggregation.collect()

self.assertEqual(first_histogram.bucket_counts, (0, 1, 0, 0))
self.assertEqual(first_histogram.sum, 1)

# CI fails the last assertion without this
sleep(0.1)
Expand All @@ -294,6 +295,7 @@ def test_collect(self):
second_histogram = explicit_bucket_histogram_aggregation.collect()

self.assertEqual(second_histogram.bucket_counts, (0, 1, 0, 0))
self.assertEqual(second_histogram.sum, 1)

self.assertGreater(
second_histogram.time_unix_nano, first_histogram.time_unix_nano
Expand Down