Signature
Overview
trace() is a context manager that creates a trace, identical to @observe but useful when decorators aren’t convenient — Jupyter notebooks, scripts, or one-off operations.
All LLM calls made inside the with block are automatically captured and associated with the trace.
Parameters
string
required
Name for the trace.
list[string]
default:"[]"
Tags for categorization.
dict
default:"{}"
Custom key-value pairs attached to the trace.
string
default:"None"
User identifier.
string
default:"None"
Session identifier.
string
default:"None"
Version string stored in trace metadata.
string
default:"auto-generated"
Explicit trace ID. A UUID is generated if not provided.
Yields
ATrace object. You can read t.id to correlate the trace with logs.
Example
Basic
With metadata
Correlating with logs
See Also
- @observe — Decorator equivalent (preferred for production functions)
- span() — Create manual spans within a trace
- get_current_trace() — Access the active trace

