diff --git a/opentelemetry-sdk/tests/metrics/test_view_instrument_match.py b/opentelemetry-sdk/tests/metrics/test_view_instrument_match.py index 38d36758f3..bda1cd3dfe 100644 --- a/opentelemetry-sdk/tests/metrics/test_view_instrument_match.py +++ b/opentelemetry-sdk/tests/metrics/test_view_instrument_match.py @@ -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(), @@ -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) @@ -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(), @@ -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(), @@ -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(), @@ -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(),