degenbot.telemetry¶
Telemetry control surface — the stable ADR-013 home for provider teardown.
The ADR-043 section-6 contract — flush every provider (spans + metrics) BEFORE the tokio runtime behind them is torn down, else the final OTLP batch exports nothing — is owned HERE, not left to call-site prose:
flush_telemetry()— the mid-run-safe flush (runner shutdown, any exit path that already knows it is torn down next).shutdown_telemetry()— the full teardown sequence: flush, then stop the runtime-backed log drainer + OTel provider. The one ordered teardown._at_exit()— registered atexit at import, so every exit path (SIGINT without runner cleanup, driver crash, plain script end) flushes.
Leaf modules import from here, never from degenbot._ffi (ADR-013: the Pydantic barrier — the _ffi seam is private to __init__.py files).
Package Contents¶
- degenbot.telemetry.shutdown_telemetry() None¶
Run the one ordered telemetry teardown: flush, then stop the machinery.
Idempotent and none-safe (telemetry off → no-op). Runs on live-callable state only: the flush executes while the runtime behind the providers is still up, so the final OTLP batch actually exports.
A flush failure is logged and does NOT skip the teardown step — the ordering survives partial-startup and degraded-exporter states.