3737@pytest .fixture (scope = "module" , autouse = True )
3838def setup_telemetry ():
3939 """Set up telemetry for all tests in this module."""
40+ import importlib
41+
42+ import mellea .telemetry .tracing
43+
4044 mp = pytest .MonkeyPatch ()
4145 mp .setenv ("MELLEA_TRACE_BACKEND" , "true" )
46+ importlib .reload (mellea .telemetry .tracing )
4247
4348 yield
4449
45- mp .undo ()
50+ mp .setenv ("MELLEA_TRACE_BACKEND" , "false" )
51+ importlib .reload (mellea .telemetry .tracing )
4652
4753
4854@pytest .fixture
@@ -67,10 +73,8 @@ def span_exporter():
6773
6874
6975@pytest .mark .asyncio
70- async def test_span_duration_captures_async_operation (span_exporter , gh_run ):
76+ async def test_span_duration_captures_async_operation (span_exporter ):
7177 """Test that span duration includes the full async operation time."""
72- if gh_run :
73- pytest .skip ("Skipping in CI - requires Ollama" )
7478
7579 backend = OllamaModelBackend (model_id = IBM_GRANITE_4_HYBRID_MICRO .ollama_name ) # type: ignore
7680 ctx = SimpleContext ()
@@ -113,17 +117,19 @@ async def test_span_duration_captures_async_operation(span_exporter, gh_run):
113117
114118
115119@pytest .mark .asyncio
116- async def test_context_propagation_parent_child (span_exporter , gh_run ):
120+ async def test_context_propagation_parent_child (span_exporter ):
117121 """Test that parent-child span relationships are maintained."""
118- if gh_run :
119- pytest .skip ("Skipping in CI - requires Ollama" )
120122
121123 backend = OllamaModelBackend (model_id = IBM_GRANITE_4_HYBRID_MICRO .ollama_name ) # type: ignore
122124 ctx = SimpleContext ()
123125 ctx = ctx .add (Message (role = "user" , content = "Say 'test' and nothing else" ))
124126
125- # Create a parent span
126- tracer = trace .get_tracer (__name__ )
127+ # Create a parent span using the module's own tracer provider
128+ # (not the global one, which may be pinned to a different provider
129+ # due to OTel's set-once semantics for set_tracer_provider)
130+ from mellea .telemetry import tracing
131+
132+ tracer = tracing ._tracer_provider .get_tracer (__name__ )
127133 with tracer .start_as_current_span ("parent_operation" ):
128134 mot , _ = await backend .generate_from_context (
129135 Message (role = "assistant" , content = "" ), ctx
@@ -158,10 +164,8 @@ async def test_context_propagation_parent_child(span_exporter, gh_run):
158164
159165
160166@pytest .mark .asyncio
161- async def test_token_usage_recorded_after_completion (span_exporter , gh_run ):
167+ async def test_token_usage_recorded_after_completion (span_exporter ):
162168 """Test that token usage metrics are recorded after async completion."""
163- if gh_run :
164- pytest .skip ("Skipping in CI - requires Ollama" )
165169
166170 backend = OllamaModelBackend (model_id = IBM_GRANITE_4_HYBRID_MICRO .ollama_name ) # type: ignore
167171 ctx = SimpleContext ()
@@ -209,10 +213,8 @@ async def test_token_usage_recorded_after_completion(span_exporter, gh_run):
209213
210214
211215@pytest .mark .asyncio
212- async def test_span_not_closed_prematurely (span_exporter , gh_run ):
216+ async def test_span_not_closed_prematurely (span_exporter ):
213217 """Test that spans are not closed before async operations complete."""
214- if gh_run :
215- pytest .skip ("Skipping in CI - requires Ollama" )
216218
217219 backend = OllamaModelBackend (model_id = IBM_GRANITE_4_HYBRID_MICRO .ollama_name ) # type: ignore
218220 ctx = SimpleContext ()
@@ -245,10 +247,8 @@ async def test_span_not_closed_prematurely(span_exporter, gh_run):
245247
246248
247249@pytest .mark .asyncio
248- async def test_multiple_generations_separate_spans (span_exporter , gh_run ):
250+ async def test_multiple_generations_separate_spans (span_exporter ):
249251 """Test that multiple generations create separate spans."""
250- if gh_run :
251- pytest .skip ("Skipping in CI - requires Ollama" )
252252
253253 backend = OllamaModelBackend (model_id = IBM_GRANITE_4_HYBRID_MICRO .ollama_name ) # type: ignore
254254 ctx = SimpleContext ()
@@ -279,10 +279,8 @@ async def test_multiple_generations_separate_spans(span_exporter, gh_run):
279279
280280
281281@pytest .mark .asyncio
282- async def test_streaming_span_duration (span_exporter , gh_run ):
282+ async def test_streaming_span_duration (span_exporter ):
283283 """Test that streaming operations have accurate span durations."""
284- if gh_run :
285- pytest .skip ("Skipping in CI - requires Ollama" )
286284
287285 from mellea .backends .model_options import ModelOption
288286
0 commit comments