process_spans()

Signature

1process_spans(spans: SpanBuffer | List[ReadableSpan]) -> bool

Processes spans through the configured processor pipeline (including the default Respan exporter and any custom processors). Returns True on success.

Example

1from respan import Respan, get_client
2
3respan = Respan(api_key="your-api-key")
4client = get_client()
5
6# Collect spans with a buffer
7with client.get_span_buffer("trace-xyz") as buffer:
8 buffer.create_span("validation", {"result": "pass"})
9 buffer.create_span("processing", {"items": 42})
10 collected = buffer.get_all_spans()
11
12# Process all collected spans at once
13success = client.process_spans(collected)
14print(f"Export successful: {success}")

Use process_spans() with spans collected from get_span_buffer(). For standard workflows using decorators, spans are exported automatically — you don’t need to call this method.