What is a trace?
Every time your agent runs, AgentVista records it as a trace. A trace captures the top-level facts about that execution:| Field | Type | Description |
|---|---|---|
trace_id | UUID | Unique identifier for this execution, generated by the SDK |
agent_name | string | The agent that produced this trace |
status | string | running, completed, failed, or timed_out |
started_at | datetime | When the run began |
ended_at | datetime | When the run finished |
duration_ms | integer | Total wall-clock time in milliseconds |
success | boolean | Optional user-defined success signal |
outcome | string | Optional outcome label (e.g. "qualified", "resolved") |
total_tokens | integer | Sum of tokens across all LLM spans in this trace |
total_cost_usd | decimal | Sum of LLM costs across all spans |
success and outcome are not set automatically — you define what success means for your agent. See Outcomes for how to attach these signals.What is a span?
A span represents one step within a trace — an LLM call, a tool invocation, a database query, or any other unit of work. Spans form a tree: every span (except the root) has aparent_span_id pointing to the span that created it.
| Field | Type | Description |
|---|---|---|
span_id | UUID | Unique identifier for this span |
trace_id | UUID | The trace this span belongs to |
parent_span_id | UUID | The parent span, or null for the root span |
type | string | The kind of work this span represents (see below) |
name | string | A human-readable label you assign |
status | string | running, completed, failed, or timed_out |
started_at | datetime | When this step began |
ended_at | datetime | When this step finished |
duration_ms | integer | Time spent in this step |
| Field | Type | Description |
|---|---|---|
model | string | The model used (e.g. "claude-sonnet-4-20250514") |
input_tokens | integer | Tokens in the prompt |
output_tokens | integer | Tokens in the completion |
total_tokens | integer | Sum of input and output |
cost_usd | decimal | Cost for this call |
input_data, output_data, error_message, and metadata as JSON payloads.
Span types
AgentVista recognizes six span types. Each type tells the dashboard how to display the span and which fields are relevant.agent
The root span of a trace. Created automatically when you use
@trace_agent or with agentvista.run(...). Represents the full lifetime of your agent’s execution.llm
An individual LLM call. Captures the model, token counts, cost, and latency for each completion request.
tool
A tool invocation — any external function, API call, or service your agent calls as part of its reasoning. Use this to track web searches, code execution, database lookups triggered by the agent, and so on.
http
An outbound HTTP request to an external service. Useful for tracking calls to third-party APIs, webhooks, or downstream microservices.
db
A database query or write operation. Helps you see whether slow agent runs are caused by the model or by database latency.
custom
Any step that doesn’t fit the above categories. Use
custom spans for arbitrary business logic, caching layers, queue operations, or anything else you want to time and observe.How spans form a tree
Spans are linked byparent_span_id. The root span (type agent) has no parent. Every span created inside the root becomes its child, and so on recursively.
started_at time, indented by its depth in the tree. You can see at a glance which steps ran in parallel, which were sequential, and where time was spent.
Unified traces
A single trace can contain both AI spans (agent, llm, tool) and infrastructure spans (http, db, custom) — this is AgentVista’s core differentiator. When your agent makes a tool call that triggers a database query, those spans appear in the same waterfall, so you can see whether a slow run was caused by the model, a downstream API, or the database.
Distributed tracing across services
If your agent calls downstream services that are also instrumented, you can stitch their spans into the same trace using W3Ctraceparent headers. The upstream service injects the header; the downstream service reads it and continues the same trace_id.
Creating spans in your code
Useagentvista.span(name, span_type) as a context manager inside any active trace. The SDK automatically links spans to the correct parent and records timing.
span() block, the span is automatically marked failed and the exception message is recorded in error_message. The exception still propagates normally — AgentVista never suppresses errors.