Spans
Spans track timed operations with automatic parent-child relationships. They’re the primary way to structure logs.Basic Usage
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
name | str | Required | Operation name |
span_type | str | "span" | Event type (span, agent, step, etc.) |
source | str | "agent" | Source (agent, world, system) |
extra | dict | None | Additional metadata |
Span Methods
log()
Add log messages to the span:set_extra()
Add metadata to the span:event_id
Get the span’s unique ID:Automatic Nesting
Spans automatically track parent-child relationships:Span Lifecycle
- Enter: Logs
"{name} started"withstarted_attimestamp - Exit (success): Logs
"{name} completed"withended_attimestamp - Exit (error): Logs
"{name} failed"with error details