flush()
flush()
Signature
Flushes all pending spans through the processor pipeline to exporters. Available on both Respan and RespanClient. The Python SDK drains pending spans automatically on normal process exit, so short-lived scripts do not need a final flush() only to make their last trace appear. Use flush() when your code needs an explicit export checkpoint while the process is still running.
Example
Do not add a final flush() to short-lived Python scripts only for normal process exit; the SDK drains pending spans automatically. Use flush() for explicit checkpoints, tests that read exported traces before exit, critical operations, and serverless/Lambda invocations that may freeze before process-exit hooks run. In long-running applications with batch processing enabled, spans are flushed automatically at regular intervals.