Span
The Span class represents a granular operation within a trace, such as an LLM call, tool execution, embedding generation, or retrieval operation. Spans can be nested to represent sub-operations. Create a Span viatrace.log_span() or span.log_span() for nested spans.
Properties
Status Values
Span status (SpanStatus) must be one of: "success", "failure", "aborted", "cancelled", "unknown".
Methods
update
Updates span fields in place. Takes adict with the fields to update. Only the keys "name", "status", "tags", "attributes", "run_evaluation", and "content" are applied; all other keys are silently ignored. Returns self for method chaining.
Parameters
Dictionary of fields to update.
Span (self, for chaining).
log_span
Creates a child Span nested under this span and adds it to the monitor buffer. The child span’sparent_reference_id is automatically set to this span’s reference_id. This is a synchronous method.
Parameters
Display name for the child span.
Span status (
SpanStatus). One of: "success", "failure", "aborted", "cancelled", "unknown".Client-side unique identifier. If omitted, a UUID is auto-generated.
Prompt identifier to associate with this span.
Deployment identifier to associate with this span.
Whether to run evaluation on this span.
Optional list of string tags.
Optional key-value metadata. Values are wrapped in
LogAttributesValue automatically.Span content payload (
LogSpanContent). Falls back to the monitor’s default_content if not provided.Span instance.
end
Marks the span as complete and ready for flushing. Automatically ends all child spans whoseparent_reference_id matches this span. Idempotent: subsequent calls return the reference ID without side effects.
str | None — the span’s reference_id.
Span Content Types
Content is wrapped usingLogSpanContent with one of the following 8 types: