Trace
The Trace class represents a high-level operation in your AI application, such as a user request or workflow execution. Traces group related spans together and are buffered in the Monitor until flushed. Create a Trace viamonitor.log_trace().
Properties
| Property | Type | Description | |
|---|---|---|---|
trace | CreateLogTraceRequest | The underlying API payload containing the trace data. Access nested fields via trace.trace (e.g. trace.trace.name, trace.trace.reference_id). | |
trace_id | `str | None` | Server-assigned trace ID, populated after the trace is flushed to the API. None until then. |
Status Values
Trace status (TraceStatus) must be one of: "success", "failure", "aborted", "cancelled", "pending", "unknown".
Methods
update
Updates trace fields in place. Takes adict with the fields to update. Only the keys "name", "status", "tags", and "attributes" 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 trace display name. |
"status" | str | Update the trace status (TraceStatus). |
"tags" | list[str] | Replace the trace tags. |
"attributes" | dict[str, Any] | Replace the trace attributes. Values are auto-wrapped in LogAttributesValue. |
Trace (self, for chaining).
log_span
Creates a child Span under this trace and adds it to the monitor buffer. This is a synchronous method.Parameters
Display name for the 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.end
Marks the trace as complete and ready for flushing. Automatically ends all child spans belonging to this trace. Idempotent: subsequent calls return the reference ID without side effects.str | None — the trace’s reference_id.