Observation types
Setas_type / asType to classify a span. Agent Registry uses the type to
decide how to render the step and which metrics apply.
Create spans
start_as_current_span / startAsCurrentSpan opens a span, makes it the
active parent for anything started inside, and closes it on exit.
start_span / startSpan for a detached span when the parent is not the
active context — a framework tracking its own run tree, a retroactive span with
an explicit start_time, or a child of a remote parent. Detached spans must be
ended explicitly.
Record model usage and cost
update sets fields on the span that spent them. Record usage and cost on the
llm span, not the root.
cost accepts input, output, and total. Provide total when your
provider bills a single figure you cannot split.
Wrap a function with observe
observe traces a function without restructuring it. It handles sync
functions, async functions, and generators.
capture_input=False / capture_output=False when the payload is large or
sensitive. For a blanket rule across every span, use
trace_content instead.
Carry identity across a run
propagate_attributes stamps association attributes onto every span started
in its scope — including spans created by third-party instrumentation you do
not control.
session_id groups traces into one session in Agent Registry. trace_name
overrides the display name of the trace, which is useful when the root span
name is generic but the run has a meaningful external label.
Deterministic trace IDs
create_trace_id(seed) derives a trace ID from a stable external key. The
same seed always produces the same trace ID, in both SDKs, byte-identical. Use
it when a run is triggered by something that already has an id — a webhook, a
ticket, a queue message — so retries and multi-service handling converge on one
trace instead of fragmenting.
Record failures
record_failure / recordFailure marks the span as errored and records the
exception without re-raising it, so tracing never changes your control flow.
Next steps
Add scores
Attach evaluation results to a trace.
Privacy controls
Mask payloads and suppress content.
Inspect a trace
What a trace looks like in Agent Registry.
Configuration
Options, environment variables, and export modes.