.agents/references/tracing-lifecycle.md
Use this reference for changes to SDK trace or span context, processors, export, flush, shutdown, resumed trace state, or sensitive-data handling. Read Realtime tracing architecture before applying these client-side rules to Realtime server traces.
ContextVar state. Async tasks inherit a snapshot when created; later changes in a child task do not rewrite the parent task's context.no-op trace or span ID.Runner may create child spans but must not finish or flush the caller's trace.RunState stores enough trace metadata to continue an interrupted run. Resume may reattach only when the trace ID was previously started in the process and the effective workflow name, group ID, metadata, and tracing key identity still match.RunState by default. A hash can verify that the caller supplied the same explicit key without persisting the secret; raw key persistence is opt-in.flush_traces() waits for queued and in-flight export work, so callers should invoke it after the trace closes when they require immediate delivery. It is not a substitute for finishing a partially built trace.TraceProvider.force_flush() and shutdown() defaulting to no-ops for compatibility with custom providers that predate these lifecycle methods.trace_include_sensitive_data=False controls captured span payload fields; it does not automatically sanitize exception objects, chaining, tracebacks, logs, or telemetry created elsewhere.__cause__, __context__, formatter failures, and model-visible error conversion when an original exception carries tool arguments or provider payloads. raise ... from None changes display, not object retention.docs/tracing.mdsrc/agents/tracing/context.pysrc/agents/tracing/scope.pysrc/agents/tracing/traces.pysrc/agents/tracing/spans.pysrc/agents/tracing/provider.pysrc/agents/tracing/processors.pysrc/agents/tracing/setup.pysrc/agents/run_state.pytests/test_trace_processor.pytests/test_tracing.pytests/test_run_state.pytests/tracing/test_import_side_effects.py