Skip to content

Commit

Permalink
[metrics] add sum attribute to Histogram (open-telemetry#2431)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Boten authored Feb 2, 2022
1 parent d71cf68 commit 57a3b17
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,5 @@ def collect(self) -> Optional[Histogram]:
bucket_counts=tuple(value),
explicit_bounds=self._boundaries,
aggregation_temporality=AggregationTemporality.DELTA,
sum=self._sum,
)
1 change: 1 addition & 0 deletions opentelemetry-sdk/src/opentelemetry/sdk/_metrics/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Histogram:
time_unix_nano: int
bucket_counts: Sequence[int]
explicit_bounds: Sequence[float]
sum: Union[int, float]
aggregation_temporality: AggregationTemporality


Expand Down
3 changes: 3 additions & 0 deletions opentelemetry-sdk/tests/metrics/test_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ def test_aggregate(self):
explicit_bucket_histogram_aggregation._bucket_counts[3], 1
)

histo = explicit_bucket_histogram_aggregation.collect()
self.assertEqual(histo.sum, 14)

def test_min_max(self):
"""
`record_min_max` indicates the aggregator to record the minimum and
Expand Down

0 comments on commit 57a3b17

Please sign in to comment.