> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-agui.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Tracing

> Gain deep visibility into your Agno agents with OpenTelemetry-based observability

<Badge icon="code-branch" color="orange">
  <Tooltip tip="Introduced in v2.3.5" cta="View release notes" href="https://github.com/agno-agi/agno/releases/tag/v2.3.5">v2.3.5</Tooltip>
</Badge>

In the systems you build with Agno, agents will make autonomous decisions, interact with external tools, and coordinate with each other in ways that aren't immediately visible from your recorded sessions alone. Observability is key to staying on top of what your agents are doing and how your system is performing.

**Agno Tracing** is the recommended way to introduce observability for your Agno agents, teams, and workflows.
It automatically captures all relevant execution details, helping you understand what your agents are doing, simplifying debugging and helping you optimize your system.

Tracing leverages [OpenTelemetry](https://opentelemetry.io/) to instrument the Agno agents and teams, capturing traces and spans.

<Frame caption="Traces stored in SQLite database viewed with AgentOS">
  <img src="https://mintcdn.com/agno-v2-agui/B_u8TpSpMOBFKmtg/images/traces-in-os.png?fit=max&auto=format&n=B_u8TpSpMOBFKmtg&q=85&s=cf4c175914c8a4829585c04e585889fa" alt="Traces viewed in AgentOS" width="2932" height="1314" data-path="images/traces-in-os.png" />
</Frame>

## Why is Observability Important?

As your Agno system become more complex (Agents using multiple tools, making sequential decisions, and coordinating with other agents), understanding its behavior becomes challenging.

**Agno Tracing** solves this:

* **Debugging**: See exactly what went wrong when an agent fails
* **Performance**: Identify bottlenecks in agent execution
* **Cost Tracking**: Monitor token usage and API calls
* **Behavior Analysis**: Understand decision-making patterns
* **Audit Trail**: Track what agents did and why

<Note>
  All Agno Tracing data is stored in your own database. No tracing data will leave your system, or be sent to third parties: you are in complete control.
</Note>

## Understanding Traces and Spans

Think of tracing like a family tree for your agent's execution:

### Trace

A **trace** represents one complete agent execution from start to finish. Each trace has a unique `trace_id` that groups all related operations together.

### Span

A **span** is a single operation within that execution. Spans form a parent-child hierarchy:

<img className="block dark:hidden" src="https://mintcdn.com/agno-v2-agui/B_u8TpSpMOBFKmtg/images/traces-vs-spans-light.png?fit=max&auto=format&n=B_u8TpSpMOBFKmtg&q=85&s=3801168e3b8d3b8390c5349abf0d6509" alt="Traces vs spans diagram" width="1827" height="930" data-path="images/traces-vs-spans-light.png" />

<img className="hidden dark:block" src="https://mintcdn.com/agno-v2-agui/B_u8TpSpMOBFKmtg/images/traces-vs-spans-dark.png?fit=max&auto=format&n=B_u8TpSpMOBFKmtg&q=85&s=0228b819cee4eaac8b484e748e96b06f" alt="Traces vs spans diagram" width="1827" height="930" data-path="images/traces-vs-spans-dark.png" />

Each span captures:

* **What happened**: Operation name (e.g., `agent.run`, `model.response`)
* **When**: Start and end timestamps
* **Context**: Input arguments, outputs, token usage
* **Relationships**: Parent span, child spans
* **Metadata**: Agent ID, session ID, run ID

## What Gets Traced

Agno automatically captures:

| Operation               | What Gets Traced                                               |
| ----------------------- | -------------------------------------------------------------- |
| **Agent Runs**          | Every `agent.run()` or `agent.arun()` call with full context   |
| **Model Calls**         | LLM interactions including prompts, responses, and token usage |
| **Tool Executions**     | Tool invocations with arguments and results                    |
| **Team Operations**     | Team coordination and member agent runs                        |
| **Workflow Operations** | Workflow coordination and step runs                            |

## Key Features

* **Zero-Code Instrumentation**: No need to modify your agent code
* **Database Storage**: Traces stored in your Agno database (SQLite, PostgreSQL, etc.)
* **Flexible Querying**: Filter by agent, session, run, or time range
* **OpenTelemetry Standard**: Export to external tools like Arize Phoenix, Langfuse
* **Non-Blocking**: Tracing never slows down your agents
* **Configurable**: Adjust batch sizes and processing for your needs

## Quick Start

<Steps>
  <Step title="Install Dependencies">
    ```bash theme={null}
    uv pip install -U opentelemetry-api opentelemetry-sdk openinference-instrumentation-agno
    ```
  </Step>

  <Step title="Enable Tracing">
    ```python theme={null}
    from agno.tracing import setup_tracing
    from agno.db.sqlite import SqliteDb

    db = SqliteDb(db_file="tmp/traces.db")
    setup_tracing(db=db) # Call this once at startup
    ```
  </Step>

  <Step title="Run Your Agent">
    ```python theme={null}
    from agno.agent import Agent
    from agno.models.openai import OpenAIResponses

    agent = Agent(
        name="My Agent",
        model=OpenAIResponses(id="gpt-5.2"),
        instructions="You are a helpful assistant",
    )

    agent.run("Hello!")  # Automatically traced!
    ```
  </Step>

  <Step title="Query Traces">
    ```python theme={null}
    traces, total = db.get_traces(agent_id=agent.id, limit=10)
    for trace in traces:
        print(f"{trace.name}: {trace.duration_ms}ms")
    ```
  </Step>
</Steps>

## Guides

<CardGroup cols={3}>
  <Card title="Basic Setup" icon="rocket" href="/tracing/basic-setup">
    Configure and enable tracing
  </Card>

  <Card title="Tracing in AgentOS" icon="rocket" href="/agent-os/tracing/overview">
    Trace your agents, teams, and workflows in AgentOS
  </Card>

  <Card title="DB Functions" icon="database" href="/tracing/db-functions">
    Query traces and spans from your database
  </Card>
</CardGroup>
