Signature
SpanBuffer context manager that routes all spans created within it into a local queue instead of exporting them immediately. This enables manual batch collection and deferred export.
Example
SpanBuffer methods
| Method | Description |
|---|---|
create_span(name, attributes=None, kind=None) | Create a span in the buffer. Returns the span ID. |
get_all_spans() | Get all buffered spans as a list. |
get_span_count() | Get the number of buffered spans. |
clear_spans() | Discard all buffered spans. |
All span creation within the buffer context (including decorator-created spans and tracer calls) is buffered. Extract spans with
get_all_spans() before exiting the context, then use client.process_spans() to export them.