logging module. It does not attach handlers or call logging.basicConfig() — your application owns root logging configuration. When you extend the SDK with custom backends, webhooks, or LLM calls, follow the same patterns so your logs stay searchable and safe in production.
Observability-related release notes live in the Changelog.
Logger hierarchy
All package loggers sit under theautoplay_sdk namespace (one logger per module via logging.getLogger(__name__)):
| Logger name | Typical use |
|---|---|
autoplay_sdk.async_client | AsyncConnectorClient connection, reconnect, parse errors |
autoplay_sdk.client | ConnectorClient (sync SSE reader) |
autoplay_sdk.buffer | EventBuffer / RedisEventBuffer |
autoplay_sdk.context_store | ContextStore / AsyncContextStore |
autoplay_sdk.chatbot | BaseChatbotWriter delivery and debounce tasks |
autoplay_sdk.summarizer | SessionSummarizer / AsyncSessionSummarizer |
autoplay_sdk.models | ActionsPayload and related parsing |
autoplay_sdk.agent_context | AsyncAgentContextWriter |
autoplay_sdk.webhook_receiver | WebhookReceiver verification and dispatch |
autoplay_sdk.rag | RagPipeline / AsyncRagPipeline |
autoplay_sdk.metrics | SdkMetricsHook wiring (minimal; prefer hook for counters) |
autoplay_sdk.integrations (e.g. integrations.intercom) contains constants and helpers only — no log records are emitted from that subpackage.
Enable debug output for the whole SDK:
Recommended pattern
- Logger per module:
logger = logging.getLogger(__name__). - Lazy formatting: use
%placeholders in the message (logger.error("failed: %s", err)), not f-strings, so arguments are not evaluated if the log level filters the record out. - Exceptions: on error paths, pass
exc_info=True(or pass the exception toexc_infowhere your framework expects it, e.g. taskdone_callbackhandlers). - Structured context: add a stable
extradict with correlation fields your team can query — for examplesession_id,product_id,conversation_id,url,event_type. Use the same key names across your integration where possible.
Error paths and tracebacks
- Inside
except SomeError as exc:preferexc_info=True(records the active exception and traceback) or passexc_info=excwhen you need to attach a specific exception instance before re-raising. - Shorthand while handling an exception:
logger.exception("msg %s", arg)is equivalent tologger.error(..., exc_info=True)for the current exception context. - For
asyncio.Taskdone_callbackhandlers (no activeexceptframe), useexc_info=t.exception()when the task failed andt.exception()is notNone— otherwise there is no traceback to record.
logger.warning(..., exc) without exc_info to avoid log volume; use exc_info=True on the final failure or at DEBUG if you need full stacks for noise.
In-repo examples: autoplay_sdk.client (ConnectorClient), autoplay_sdk.rag (RagPipeline), autoplay_sdk.webhook_receiver (WebhookReceiver), and autoplay_sdk.agent_context (AsyncAgentContextWriter).
Subclassing BaseChatbotWriter
If you implement a custom chatbot destination in your package, define logger = logging.getLogger(__name__) in your module (not under autoplay_sdk). Follow the same % formatting, exc_info, and extra rules so your logs compose cleanly with SDK lines in shared aggregators.
Do not log secrets
- API keys, bearer tokens, cookies, and signing secrets — including material used for HMAC verification (e.g. raw webhook signing payloads or shared secrets).
- Full HTTP request and response bodies — especially in webhook-heavy apps. Bodies are the most common accidental leak vector: they often contain tokens, session cookies, or PII. Prefer logging a short prefix, status code, and correlation ids; redact or omit bodies unless you have a deliberate, reviewed redaction pipeline.
- Full user or session payloads unless redacted or truncated to non-sensitive fields.
When extra is sparse
Some SDK code paths only know session_id (for example failures inside overwrite_with_summary before your callback runs). If you need product_id or other fields in those logs, thread them through your own layer (wrapper, context var, or subclass) — the SDK does not add new parameters for logging-only data in this release.
Common mistake
Logging the exception message without a traceback loses the stack you need for production debugging. Omittingextra makes it hard to tie a line to a session or product in your log platform.
extra to non-sensitive correlation fields; never put secrets or raw bodies there.