Starting a trace
pandaprobe.start_trace() parameters:
Returns a
TraceContext with:
trace_idproperty — the auto-generated trace UUID (read-only)span()method — creates child spansset_input(data)— update trace inputset_output(data)— set trace outputset_metadata(dict)— merge metadataset_status(status)— setTraceStatus(PENDING,RUNNING,COMPLETED,ERROR)
Creating spans
t.span() parameters:
SpanContext methods
span_id property — read-only UUID of the span.
Token and cost fields
Token and cost fields
set_token_usage and set_cost accept additional keyword arguments so you can record provider-specific breakdowns without losing structured data in the UI.Nested spans
Spans can be nested to form a tree. Parent-child relationships are tracked automatically via a context-var span stack:llm-call and tool-call spans are automatically parented to the agent span.
Error handling
On exception within a span, the status is automatically set toERROR and the error message is captured. The exception is re-raised.
Because exceptions propagate, you can rely on normal
try / except boundaries around your instrumentation while still recording span-level failures.Sync and async support
BothTraceContext and SpanContext work as sync or async context managers.
- Sync
- Async

