Skip to content

Commit

Permalink
Fix main otel logger test (apache#42246)
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrejeambrun authored Sep 16, 2024
1 parent a5d0a63 commit f3b238a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/core/test_otel_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit f3b238a

Please sign in to comment.