flush()

Signature

1flush() -> None

Flushes all pending spans through the processor pipeline to exporters. Available on both Respan and RespanClient.

Example

1from respan import Respan, get_client, workflow
2
3respan = Respan(api_key="your-api-key")
4
5@workflow(name="quick_task")
6def quick_task():
7 return "done"
8
9quick_task()
10
11# Flush via Respan instance
12respan.flush()
13
14# Or flush via client
15get_client().flush()

Use flush() before process exit or in serverless/Lambda environments to ensure all spans are exported. In long-running applications with batch processing enabled, spans are flushed automatically at regular intervals.