Multi-DB Tracing with setup_tracing()
Trace agents with multiple databases using setup_tracing() in AgentOS.
Configure tracing with setup_tracing() when agents have separate databases. A dedicated tracing database ensures all traces are stored in one central location.
Tracing is process-wide. If a real OpenTelemetry TracerProvider already exists, setup_tracing() returns without installing a new exporter or changing its database. Start these examples in a fresh process, or configure the existing provider deliberately; a later AgentOS instance does not redirect its exporters.
Create a Python file
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.os import AgentOS
from agno.tools.hackernews import HackerNewsTools
from agno.tools.websearch import WebSearchTools
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
db = SqliteDb(db_file="tmp/traces.db", id="traces")
# Setup tracing with custom configuration
setup_tracing(
db=db,
batch_processing=True,
max_queue_size=1024,
max_export_batch_size=256,
)
agent = Agent(
name="HackerNews Agent",
model=OpenAIResponses(id="gpt-5.2"),
tools=[HackerNewsTools()],
instructions="You are a hacker news agent. Answer questions concisely.",
markdown=True,
db=db1,
)
agent2 = Agent(
name="Web Search Agent",
model=OpenAIResponses(id="gpt-5.2"),
tools=[WebSearchTools()],
instructions="You are a web search agent. Answer questions concisely.",
markdown=True,
db=db2,
)
# Setup AgentOS with dedicated 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],
db=db, # Dedicated database for traces
)
app = agent_os.get_app()
if __name__ == "__main__":
agent_os.serve(app="tracing_multi_db_setup:app", reload=True)Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U openai ddgs "agno[os]" opentelemetry-api opentelemetry-sdk openinference-instrumentation-agnoExport your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"Run AgentOS
python tracing_multi_db_setup.pyYour AgentOS will be available at http://localhost:7777. View traces in the AgentOS dashboard.