Skip to content
Draft
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
18 changes: 8 additions & 10 deletions opentelemetry-sdk/tests/metrics/test_view_instrument_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def test_collect_resets_start_time_unix_nano(self, mock_time_ns):
view_instrument_match.consume_measurement(
Measurement(
value=0,
time_unix_nano=time_ns(),
time_unix_nano=123,
instrument=instrument,
attributes={"foo": "bar0"},
context=Context(),
Expand All @@ -303,9 +303,8 @@ def test_collect_resets_start_time_unix_nano(self, mock_time_ns):
_default_reservoir_factory,
start_time_unix_nano,
)
collection_start_time_unix_nano = time_ns()
collected_data_points = view_instrument_match.collect(
AggregationTemporality.CUMULATIVE, collection_start_time_unix_nano
AggregationTemporality.CUMULATIVE, 456
)
self.assertIsNotNone(collected_data_points)
self.assertEqual(len(collected_data_points), 1)
Expand All @@ -314,7 +313,7 @@ def test_collect_resets_start_time_unix_nano(self, mock_time_ns):
view_instrument_match.consume_measurement(
Measurement(
value=0,
time_unix_nano=time_ns(),
time_unix_nano=789,
instrument=instrument,
attributes={"foo": "bar1"},
context=Context(),
Expand All @@ -323,20 +322,19 @@ def test_collect_resets_start_time_unix_nano(self, mock_time_ns):
view_instrument_match._view._aggregation._create_aggregation.assert_called_with(
instrument, {"foo": "bar1"}, _default_reservoir_factory, 1
)
collection_start_time_unix_nano = time_ns()
collected_data_points = view_instrument_match.collect(
AggregationTemporality.CUMULATIVE, collection_start_time_unix_nano
AggregationTemporality.CUMULATIVE, 999
)
self.assertIsNotNone(collected_data_points)
self.assertEqual(len(collected_data_points), 2)
collected_data_points = view_instrument_match.collect(
AggregationTemporality.CUMULATIVE, collection_start_time_unix_nano
AggregationTemporality.CUMULATIVE, 999
)
# +1 call to create_aggregation
view_instrument_match.consume_measurement(
Measurement(
value=0,
time_unix_nano=time_ns(),
time_unix_nano=1000,
instrument=instrument,
attributes={"foo": "bar"},
context=Context(),
Expand All @@ -349,7 +347,7 @@ def test_collect_resets_start_time_unix_nano(self, mock_time_ns):
view_instrument_match.consume_measurement(
Measurement(
value=0,
time_unix_nano=time_ns(),
time_unix_nano=1001,
instrument=instrument,
attributes={"foo": "bar"},
context=Context(),
Expand All @@ -358,7 +356,7 @@ def test_collect_resets_start_time_unix_nano(self, mock_time_ns):
view_instrument_match.consume_measurement(
Measurement(
value=0,
time_unix_nano=time_ns(),
time_unix_nano=1002,
instrument=instrument,
attributes={"foo": "bar"},
context=Context(),
Expand Down