From f3b238ae7f9101c32a52c491af74112bcdcb25b8 Mon Sep 17 00:00:00 2001 From: Pierre Jeambrun Date: Mon, 16 Sep 2024 20:02:16 +0800 Subject: [PATCH] Fix main otel logger test (#42246) --- tests/core/test_otel_logger.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/core/test_otel_logger.py b/tests/core/test_otel_logger.py index d5697e585b45c..9f6ba8ca964e3 100644 --- a/tests/core/test_otel_logger.py +++ b/tests/core/test_otel_logger.py @@ -304,15 +304,25 @@ def test_timer_no_name_returns_float_but_does_not_store_value(self, mock_time, n assert mock_time.call_count == 2 self.meter.get_meter().create_observable_gauge.assert_not_called() + @pytest.mark.parametrize( + "metrics_consistency_on", + [ + True, + False, + ], + ) @mock.patch.object(time, "perf_counter", side_effect=[0.0, 3.14]) - def test_timer_start_and_stop_manually_send_false(self, mock_time, name): + def test_timer_start_and_stop_manually_send_false(self, mock_time, metrics_consistency_on, name): + protocols.metrics_consistency_on = metrics_consistency_on + timer = self.stats.timer(name) timer.start() # Perform some task timer.stop(send=False) assert isinstance(timer.duration, float) - assert timer.duration == 3.14 + expected_value = 3140.0 if metrics_consistency_on else 3.14 + assert timer.duration == expected_value assert mock_time.call_count == 2 self.meter.get_meter().create_observable_gauge.assert_not_called()