Skip to main content
A trace represents one complete execution of your agent or request flow. A span is a single step inside that trace. Together, they give you an end-to-end picture of what happened, how long each step took, and where things went wrong.

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:
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 a parent_span_id pointing to the span that created it. LLM spans carry additional fields: All span types can carry 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 by parent_span_id. The root span (type agent) has no parent. Every span created inside the root becomes its child, and so on recursively.
The AgentVista dashboard renders this tree as a waterfall timeline — each span appears as a horizontal bar positioned by its 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 W3C traceparent headers. The upstream service injects the header; the downstream service reads it and continues the same trace_id.

Creating spans in your code

Use agentvista.span(name, span_type) as a context manager inside any active trace. The SDK automatically links spans to the correct parent and records timing.
agentvista.span() is a no-op when called outside an active trace. You can safely add spans to library code without worrying about whether a trace is running.
If an exception is raised inside a 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.