-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_observability.py
More file actions
61 lines (43 loc) · 2.25 KB
/
Copy pathtest_observability.py
File metadata and controls
61 lines (43 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Tests for evalwire.observability.setup_observability."""
from unittest.mock import MagicMock, patch
class TestSetupObservability:
def test_calls_register_with_auto_instrument_true(self):
mock_provider = MagicMock()
with patch(
"phoenix.otel.register", return_value=mock_provider, create=True
) as mock_register:
from evalwire.observability import setup_observability
result = setup_observability()
mock_register.assert_called_once_with(auto_instrument=True)
assert result is mock_provider
def test_calls_register_with_auto_instrument_false(self):
mock_provider = MagicMock()
with patch(
"phoenix.otel.register", return_value=mock_provider, create=True
) as mock_register:
from evalwire.observability import setup_observability
result = setup_observability(auto_instrument=False)
mock_register.assert_called_once_with(auto_instrument=False)
assert result is mock_provider
def test_instruments_each_instrumentor(self):
mock_provider = MagicMock()
inst_a = MagicMock()
inst_b = MagicMock()
with patch("phoenix.otel.register", return_value=mock_provider, create=True):
from evalwire.observability import setup_observability
setup_observability(instrumentors=[inst_a, inst_b])
inst_a.instrument.assert_called_once_with(tracer_provider=mock_provider)
inst_b.instrument.assert_called_once_with(tracer_provider=mock_provider)
def test_no_instrumentors_none(self):
mock_provider = MagicMock()
with patch("phoenix.otel.register", return_value=mock_provider, create=True):
from evalwire.observability import setup_observability
# Should not raise when instrumentors is None (default)
result = setup_observability(instrumentors=None)
assert result is mock_provider
def test_empty_instrumentors_list(self):
mock_provider = MagicMock()
with patch("phoenix.otel.register", return_value=mock_provider, create=True):
from evalwire.observability import setup_observability
result = setup_observability(instrumentors=[])
assert result is mock_provider