Skip to main content
This guide walks you through setting up tracing for your Agno agents. Tracing is designed to be simple: install dependencies, enable tracing, and all your agents are automatically instrumented.

Installation

Install the required OpenTelemetry packages:
These packages provide the OpenTelemetry instrumentation infrastructure and the Agno-specific instrumentation logic.

Two Ways to Enable Tracing

There are two ways to enable tracing in Agno:
  1. setup_tracing() - Use this function for standalone scripts, notebooks, and custom applications. Provides full control over configuration options like batch processing, queue sizes, and export delays.
  2. AgentOS tracing=True - Use this parameter when deploying agents through AgentOS. Simpler setup for production deployments with sensible defaults.

Option 1: Using tracing with SDK

For standalone scripts, notebooks, or custom applications use setup_tracing():
Call setup_tracing() before creating your agents. This ensures the instrumentation is active when agents are initialized.

Option 2: Using tracing with AgentOS

When deploying agents with AgentOS, you can enable tracing with a simple parameter:
You can also use setup_tracing() to configure tracing for AgentOS but make sure to pass the db to AgentOS so traces are accessible through the AgentOS API and UI.
db is required in AgentOS to ensure traces are accessible through the AgentOS API and UI.
For detailed AgentOS tracing configuration including multi-database setups, see Tracing in AgentOS.

Dedicated Traces Database

Recommended: Use a separate database for storing traces, especially when you have multiple agents or teams with their own databases.
When agents and teams each have their own databases for sessions and memory, traces should go to a dedicated central database. This ensures:
  • Unified observability: All traces in one place for cross-agent analysis
  • Simpler querying: No need to search multiple databases
  • Independent scaling: Traces can grow independently from agent data
  • Cleaner separation: Agent data and observability data don’t mix
Once configured, traces and spans are automatically stored in your database. The tracing system creates two tables: agno_traces for high-level trace information and agno_spans for individual span details.
Database view showing agno_spans table with trace data including span_id, trace_id, parent_span_id, and operation names
Each span record includes the trace_id to group related operations, parent_span_id for hierarchy, and the operation name (e.g., Stock_Price_Agent.run, OpenAIChat.invoke, get_current_stock_price).

Processing Modes

Agno supports two trace processing modes:

Batch Processing

Batch processing collects traces in memory and writes them in batches. This is more efficient and recommended for production:
Pros:
  • Lower database load
  • Better performance
  • Minimal impact on agent execution
Cons:
  • Slight delay before traces appear (default 5 seconds)
  • Traces in memory if application crashes before export

Simple Processing (Default)

Simple processing writes each trace immediately:
Pros:
  • Traces appear immediately
  • No memory buffering
Cons:
  • More database writes
  • Slight performance overhead
Use batch processing in production and simple processing for development/debugging when you need immediate trace visibility.

Next Steps

DB Functions

Query traces and spans from your database