withTrace/withSpan for callback functions or trace/span for native class-method decorators (legacy and Stage 3 forms). A TraceContext can own a callback with run, or be explicitly entered and ended. Always finish explicit contexts. Session/user callback scopes use AsyncLocalStorage. TraceCapture is a type-only root export: obtain it from client.captureTraces(...) and call run(...).
On this page
SpanContext, SpanContextOptions, SpanDecoratorOptions, TraceCapture, TraceCaptureOptions, TraceContext, TraceContextOptions, TraceDecoratorOptions, WithSpanOptions, WithTraceOptions, getCurrentTrace, getSpanStack, session, setSession, setUser, span, startTrace, trace, user, withSpan, withTrace.Example
SpanContext
Constructor
Fields and properties
Methods
getOutput
getOutput
The output recorded on this span (used to mirror it onto standalone traces).
getTraceContext
getTraceContext
The trace this span belongs to (used to attach sibling/child tool spans).
start
start
Enter the span: record start time, set parent, push onto the trace’s stack.
end
end
End the span: record end time/status, finalize, pop from the trace’s stack.
run
run
Run fn within this span (callback form).
instrument
instrument
Wrap a sync-or-async invocation in this span (decorator form). Sets the
given input, captures the return value as output, and preserves the
original return type (sync stays sync, async stays async).
setInput
setInput
Sets the recorded input. Trace and LLM inputs use the messages schema; other span kinds may use domain values.
setOutput
setOutput
Sets the recorded output. Trace and LLM outputs use the messages schema; other span kinds may use domain values.
setTokenUsage
setTokenUsage
Records supplied token counts and additional numeric usage. This setter does not measure token use itself.
setModel
setModel
Records the model identifier for this span.
setModelParameters
setModelParameters
Records the supplied model invocation parameters.
setCost
setCost
Records supplied total cost and any additional named cost components. It does not look up provider prices.
setCompletionStartTime
setCompletionStartTime
Records the time completion output began, such as the first streamed token.
setError
setError
Records an error message and sets the span status to ERROR.
setMetadata
setMetadata
Merges metadata into the current record; existing keys with the same name are replaced.
SpanContextOptions
Fields and properties
SpanDecoratorOptions
Fields and properties
TraceCapture
Constructor
Fields and properties
Methods
run
run
TraceCaptureOptions
Fields and properties
TraceContext
Constructor
Fields and properties
Methods
start
start
Enter the trace context imperatively. Pair with
end().end
end
End the trace, finalize, and restore the previous ambient context.
run
run
Run fn within this trace’s context (callback form).
instrument
instrument
Wrap a sync-or-async invocation in this trace’s context (decorator form).
span
span
setOutput
setOutput
Sets the recorded output. Trace and LLM outputs use the messages schema; other span kinds may use domain values.
setInput
setInput
Sets the recorded input. Trace and LLM inputs use the messages schema; other span kinds may use domain values.
setMetadata
setMetadata
Merges metadata into the current record; existing keys with the same name are replaced.
setStatus
setStatus
Sets the trace status using a supported TraceStatus value.
addSpanData
addSpanData
TraceContextOptions
Fields and properties
TraceDecoratorOptions
Fields and properties
WithSpanOptions
Fields and properties
WithTraceOptions
Fields and properties
getCurrentTrace
getSpanStack
session
with pandaprobe.session(id):).
Type parameters: T.
Source declaration
setSession
setUser
span
SpanContext.
Source declaration
startTrace
TraceContext, already entered.
Source declaration
trace
TraceContext.
Source declaration
user
T.
Source declaration
withSpan
T.
Source declaration
withTrace
T.
Source declaration
Signatures and fields are generated from the SDK source. See the import index for available entry points.

