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
| Property | Type | Description |
|---|---|---|
span | CreateLogSpanRequest | The underlying API payload containing the span data. Access nested fields via span.span (e.g. span.span.name, span.span.reference_id). |
trace | Trace | The parent Trace this span belongs to. |
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.
| Key | Type | Description |
|---|---|---|
"name" | str | Update the span display name. |
"status" | str | Update the span status (SpanStatus). |
"tags" | list[str] | Replace the span tags. |
"attributes" | dict[str, Any] | Replace the span attributes. Values are auto-wrapped in LogAttributesValue. |
"run_evaluation" | bool | Whether to run evaluation on this span. |
"content" | LogSpanContent | Replace the span content payload. |
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: