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
Name for the trace.
Tags for categorization.
Custom key-value pairs attached to the trace.
User identifier.
Session identifier.
Version string stored in trace metadata.
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

