Skip to content

[FAQ] Why doesn't my SQLite exporter receive any spans after I switch from ConsoleSpanExporter in Module 5 (Monitoring)? #329

Description

@c-ibarra

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:

  1. 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.
  2. 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

  • I have searched existing FAQs and this question is not already answered
  • The answer provides accurate, helpful information
  • I have included any relevant code examples or links

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions