Course
llm-zoomcamp
Question
Why doesn't my SQLite exporter receive any spans after I switch from ConsoleSpanExporter in Module 5 (Monitoring)?
Answer
If you follow the homework literally and build a second TracerProvider() in the same notebook kernel to swap from ConsoleSpanExporter to your SQLiteSpanExporter, calling trace.set_tracer_provider(provider) a second time is a silent no-op: OpenTelemetry only allows the global provider to be registered once per process, so trace.get_tracer(...) keeps returning a tracer bound to the first provider (the console one). Your spans keep printing to the console and traces.db stays empty.
Two ways to fix it:
- Skip global registration entirely: get the tracer straight from the provider object with
tracer = provider.get_tracer("llm-zoomcamp") instead of trace.set_tracer_provider(...) + trace.get_tracer(...). Each TracerProvider you build stays independent, so you can freely swap exporters within one kernel.
- Restart the kernel between exporter swaps, matching the homework's implicit assumption of separate script runs.
This only bites you in a persistent process (Jupyter kernel, ipython); running the homework as separate python script.py invocations never hits it, since each run is a fresh process.
Checklist
Course
llm-zoomcamp
Question
Why doesn't my SQLite exporter receive any spans after I switch from ConsoleSpanExporter in Module 5 (Monitoring)?
Answer
If you follow the homework literally and build a second
TracerProvider()in the same notebook kernel to swap fromConsoleSpanExporterto yourSQLiteSpanExporter, callingtrace.set_tracer_provider(provider)a second time is a silent no-op: OpenTelemetry only allows the global provider to be registered once per process, sotrace.get_tracer(...)keeps returning a tracer bound to the first provider (the console one). Your spans keep printing to the console andtraces.dbstays empty.Two ways to fix it:
tracer = provider.get_tracer("llm-zoomcamp")instead oftrace.set_tracer_provider(...)+trace.get_tracer(...). EachTracerProvideryou build stays independent, so you can freely swap exporters within one kernel.This only bites you in a persistent process (Jupyter kernel,
ipython); running the homework as separatepython script.pyinvocations never hits it, since each run is a fresh process.Checklist