Skip to content

Commit 1a48c8a

Browse files
SS-90: Document set_tracer_provider one-time-global invariant
Copilot flagged that trace.set_tracer_provider() is a one-time global and a pre-existing provider could cause spans to be lost. Add a design note explaining why this cannot happen in SmartFix: ADK's OTel setup only runs from its CLI web server (not the Runner API we use), and LiteLLM's OTel integration requires explicit callback configuration.
1 parent 5d7af87 commit 1a48c8a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/smartfix/domains/telemetry/otel_provider.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
no-ops with no guards needed in callers.
3030
- force_flush() called before shutdown() to flush the BatchSpanProcessor background thread
3131
before sys.exit() can kill it.
32+
- trace.set_tracer_provider() is a one-time global; subsequent calls are silently ignored
33+
by the SDK. No SmartFix dependency installs a TracerProvider ahead of initialize_otel():
34+
ADK's OTel setup (maybe_set_otel_providers) is only called from the ADK CLI web server,
35+
not from the Runner API that SmartFix uses; LiteLLM's OTel integration requires explicit
36+
callback configuration. initialize_otel() is therefore always the first caller.
3237
"""
3338

3439
import os

0 commit comments

Comments
 (0)