- Critical workflow points: To ensure data is persisted before sensitive operations or transitions in a distributed workflow.
- Debugging: To see tracing data appear on the Traces page immediately during development.
How to Flush Tracing Data
The SDK provides methods to manually trigger data export:Flushing the entire queue
Usetracing.flush_queue()
to force a synchronous export of all spans currently buffered in the SDK’s internal queue. This method will block the calling thread until all pending spans have been sent.
Flushing individual spans or traces
You can also explicitly flush an individualSpan
object. When you call span.flush()
, that specific span will be sent. For Trace
objects, flushing (trace.flush()
) will send the root span.
By default,
span.flush()
and trace.flush()
are blocking operations. This means the calling thread will pause until the data is successfully sent to the SGP platform.For non-blocking behavior (recommended in performance-sensitive applications), pass blocking=False
:Automatic Shutdown Flush
You typically do not need to manually callflush_queue()
at the very end of your program. When the SDK’s background worker is shut down (e.g., when your Python application exits normally), it will automatically attempt to flush any remaining tracing data in the queue before exiting.