Skip to content

Commit

Permalink
Set _LastValueAggregation start_time_unix_nano to None (open-telemetr…
Browse files Browse the repository at this point in the history
…y#4004)

* Sest _LastValueAggregation start_time_unix_nano to None

Fixes open-telemetry#3678

* Use None in test utils too

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
  • Loading branch information
ocelotl and xrmx committed Jul 11, 2024
1 parent 7237f78 commit 0115d2f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ def test_encode_gauge_int(self):
),
],
time_unix_nano=1641946016139533244,
start_time_unix_nano=0,
as_int=9000,
)
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def collect(

return NumberDataPoint(
attributes=self._attributes,
start_time_unix_nano=0,
start_time_unix_nano=None,
time_unix_nano=collection_start_nano,
value=value,
)
Expand Down
4 changes: 4 additions & 0 deletions opentelemetry-sdk/tests/metrics/test_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ def test_collect(self):

self.assertEqual(first_number_data_point.value, 1)

self.assertIsNone(first_number_data_point.start_time_unix_nano)

last_value_aggregation.aggregate(measurement(1))

# CI fails the last assertion without this
Expand All @@ -249,6 +251,8 @@ def test_collect(self):

self.assertEqual(second_number_data_point.value, 1)

self.assertIsNone(second_number_data_point.start_time_unix_nano)

self.assertGreater(
second_number_data_point.time_unix_nano,
first_number_data_point.time_unix_nano,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _generate_gauge(
data_points=[
NumberDataPoint(
attributes=attributes,
start_time_unix_nano=1641946015139533244,
start_time_unix_nano=None,
time_unix_nano=1641946016139533244,
value=value,
)
Expand Down

0 comments on commit 0115d2f

Please sign in to comment.