Skip to main content
This example shows how to configure tracing when agents have separate databases using setup_tracing(). A dedicated tracing database ensures all traces are stored in one central location.
1

Create a Python file

touch tracing_multi_db_setup.py
2

Add the following code to your Python file

tracing_multi_db_setup.py
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIChat
from agno.os import AgentOS
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.hackernews import HackerNewsTools
from agno.tracing import setup_tracing

# Set up databases - each agent has its own db
db1 = SqliteDb(db_file="tmp/db1.db", id="db1")
db2 = SqliteDb(db_file="tmp/db2.db", id="db2")

# Dedicated traces database
tracing_db = SqliteDb(db_file="tmp/traces.db", id="traces")

# Setup tracing with custom configuration
setup_tracing(
    db=tracing_db,
    batch_processing=True,
    max_queue_size=1024,
    max_export_batch_size=256,
)

agent = Agent(
    name="HackerNews Agent",
    model=OpenAIChat(id="gpt-5-mini"),
    tools=[HackerNewsTools()],
    instructions="You are a hacker news agent. Answer questions concisely.",
    markdown=True,
    db=db1,
)

agent2 = Agent(
    name="Web Search Agent",
    model=OpenAIChat(id="gpt-5-mini"),
    tools=[DuckDuckGoTools()],
    instructions="You are a web search agent. Answer questions concisely.",
    markdown=True,
    db=db2,
)

# Setup AgentOS with dedicated tracing_db
# This ensures traces are written to and read from the same database
agent_os = AgentOS(
    description="Example app for tracing with multiple databases",
    agents=[agent, agent2],
    tracing_db=tracing_db,  # Dedicated database for traces
)
app = agent_os.get_app()

if __name__ == "__main__":
    agent_os.serve(app="tracing_multi_db_setup:app", reload=True)
3

Create a virtual environment

Open the Terminal and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
4

Install libraries

pip install -U openai agno opentelemetry-api opentelemetry-sdk openinference-instrumentation-agno
5

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"
6

Run AgentOS

python tracing_multi_db_setup.py
Your AgentOS will be available at http://localhost:7777. View traces in the AgentOS dashboard.