Traces
A trace represents a single end-to-end operation in your application—typically one user request or agent run. Every trace has:trace_id— auto-generated UUIDname— a descriptive name (for example,customer-support-agent)status— one of:PENDING,RUNNING,COMPLETED,ERRORinput/output— the request and response datasession_id/user_id— for grouping related tracestags— arbitrary string labelsmetadata— arbitrary key-value pairsenvironment/release— from SDK configurationspans— ordered list of spans (maximum 500 per trace)
Spans
A span represents a single unit of work within a trace. Spans can be nested to form a tree. Every span has:span_id— auto-generated UUIDparent_span_id— links to the parent span (nullfor root spans)name— descriptive namekind— categorizes the type of work (see SpanKind below)status—UNSET,OK, orERRORinput/output— span-level datamodel— the LLM model name (for LLM spans)token_usage— dict withprompt_tokens,completion_tokens,total_tokens, and optionallyreasoning_tokens,cache_read_tokensmodel_parameters— dict withtemperature,top_p,max_tokens, and similar fieldscost— dict withtotaland optionally other breakdownscompletion_start_time— timestamp of first token (time-to-first-token)metadata— arbitrary key-value pairserror— error message string if the span failed
SpanKind
| Value | Description |
|---|---|
LLM | A call to a language model API |
TOOL | A tool or function call execution |
AGENT | An autonomous agent step or sub-agent |
CHAIN | A chain or pipeline of operations |
RETRIEVER | A retrieval operation (for example, vector search) |
EMBEDDING | An embedding generation call |
OTHER | Any other operation |
SpanStatusCode
| Value | Description |
|---|---|
UNSET | Status not explicitly set (default) |
OK | Operation completed successfully |
ERROR | Operation failed |
UNSET to OK. On exception, status is set to ERROR.
TraceStatus
| Value | Description |
|---|---|
PENDING | Trace created but not started |
RUNNING | Trace is actively executing |
COMPLETED | Trace finished successfully |
ERROR | Trace failed with an error |
Input/Output convention
LLM spans use a standard messages format:input contains only the last user message and output contains only the last assistant message. This convention is enforced automatically by wrappers, integrations, and the @trace decorator.
The messages format is validated but non-conforming data is accepted with a warning. You can pass arbitrary JSON as input/output if needed.
Span status: UNSET to OK
Span status: UNSET to OK
If a span exits without error and you never set an explicit status, the SDK promotes
UNSET to OK. If an exception propagates out of the instrumented region, the span is marked ERROR and error details are attached when available.Trace status lifecycle
Trace status lifecycle
Traces typically move
PENDING to RUNNING while work is in flight, then COMPLETED on success or ERROR when the trace fails. Final status drives aggregation and alerting in downstream tooling.