Skip to main content
A single logical operation often makes several LLM calls brainstorm then summarize, retrieve then answer. ff.withTrace() wraps that work so all the calls inside share one trace_id and a parent row lands in firstflow_traces.

Options

name
string
Human-readable label for the operation, stored on the trace.
userId
string
The user the operation belongs to.
metadata
Record<string, unknown>
Arbitrary tags stored on the trace row.
inputState
unknown
Optional snapshot of the operation’s inputs.
traceId
string
Provide an explicit id to correlate with an upstream request; otherwise one is generated. ff.newTraceId() mints one ahead of time.

How it works

withTrace uses AsyncLocalStorage to make the trace id ambient: any wrapped call inside the callback picks it up automatically you don’t thread it through. On completion it records the parent trace (latency = wall-clock of the whole operation); if the callback throws, the trace is recorded with is_error and the message, then the error re-throws.

Querying a trace and its calls

Next

See the full row shapes in What gets recorded, or classify the conversation in Intent & sentiment.