process_spans()

Signature

process_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

from respan import Respan, get_client
respan = Respan(api_key="your-api-key")
client = get_client()
# Collect spans with a buffer
with client.get_span_buffer("trace-xyz") as buffer:
buffer.create_span("validation", {"result": "pass"})
buffer.create_span("processing", {"items": 42})
collected = buffer.get_all_spans()
# Process all collected spans at once
success = client.process_spans(collected)
print(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.