OpenLIT
Integrate Agno with OpenLIT for OpenTelemetry-native observability, tracing, and monitoring of your AI agents.
Integrating Agno with OpenLIT
OpenLIT is an open-source, self-hosted, OpenTelemetry-native platform for a continuous feedback loop for testing, tracing, and fixing AI agents. By integrating Agno with OpenLIT, you can automatically instrument your agents to gain full visibility into LLM calls, tool usage, costs, performance metrics, and errors.
Prerequisites
-
Install Dependencies
Ensure you have the necessary packages installed:
uv pip install agno openai openlit yfinance -
Deploy OpenLIT
OpenLIT is open-source and self-hosted. Quick start with Docker:
git clone https://github.com/openlit/openlit cd openlit docker compose up -dAccess the dashboard at
http://127.0.0.1:3000with default credentials (username:user@openlit.io, password:openlituser).Other Deployment Options:
For production deployments, Kubernetes with Helm, or other infrastructure setups, see the OpenLIT Installation Guide for detailed instructions on:
- Kubernetes deployment with Helm charts
- Custom Docker configurations
- Reusing existing ClickHouse or OpenTelemetry Collector infrastructure
- OpenLIT Operator for zero-code instrumentation in Kubernetes
-
Set your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here" -
Set the OpenLIT endpoint (Optional)
Configure the OTLP endpoint based on your deployment:
# Local deployment export OTEL_EXPORTER_OTLP_ENDPOINT="http://127.0.0.1:4318" # Self-hosted on your infrastructure export OTEL_EXPORTER_OTLP_ENDPOINT="http://your-openlit-host:4318"
Sending Traces to OpenLIT
Example: Basic Agent Setup
Instrument your Agno agent with OpenLIT for automatic tracing.
import openlit
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.yfinance import YFinanceTools
# Initialize OpenLIT instrumentation
openlit.init(
otlp_endpoint="http://127.0.0.1:4318" # Your OpenLIT OTLP endpoint
)
# Create and configure the agent
agent = Agent(
name="Stock Price Agent",
model=OpenAIResponses(id="gpt-5.2"),
tools=[YFinanceTools(enable_stock_price=True, enable_analyst_recommendations=True)],
instructions="You are a stock price agent. Answer questions in the style of a stock analyst.",
)
# Use the agent - all calls are automatically traced
agent.print_response("What is the current price of Tesla and what do analysts recommend?")Example: Development Mode (Console Output)
Run this alternative in a fresh Python process to print traces without a collector. It explicitly selects the console trace exporter and disables metric and event export:
import openlit
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.hackernews import HackerNewsTools
# Select console traces even if a previous shell step set an OTLP endpoint
import os
os.environ["OTEL_TRACES_EXPORTER"] = "console"
openlit.init(disable_batch=True, disable_metrics=True, disable_events=True)
# Create and configure the agent
agent = Agent(
name="HackerNews Agent",
model=OpenAIResponses(id="gpt-5.2"),
tools=[HackerNewsTools()],
instructions="Use HackerNews to provide comprehensive answers.",
markdown=True,
)
# Use the agent - traces will be printed to console
agent.print_response("What are the top stories on HackerNews right now?")Example: Multi-Agent Team Tracing
OpenLIT automatically traces complex multi-agent workflows:
import openlit
from agno.agent import Agent
from agno.team import Team
from agno.models.openai import OpenAIResponses
from agno.tools.hackernews import HackerNewsTools
from agno.tools.yfinance import YFinanceTools
# Initialize OpenLIT instrumentation
openlit.init(otlp_endpoint="http://127.0.0.1:4318")
# Research Agent
research_agent = Agent(
name="Market Research Agent",
model=OpenAIResponses(id="gpt-5.2"),
tools=[HackerNewsTools()],
instructions="Research current market conditions and news",
)
# Financial Analysis Agent
finance_agent = Agent(
name="Financial Analyst",
model=OpenAIResponses(id="gpt-5.2"),
tools=[YFinanceTools(enable_stock_price=True, enable_company_info=True)],
instructions="Perform quantitative financial analysis",
)
# Coordinated Team
finance_team = Team(
name="Finance Research Team",
model=OpenAIResponses(id="gpt-5.2"),
members=[research_agent, finance_agent],
instructions=[
"Collaborate to provide comprehensive financial insights",
"Consider both fundamental analysis and market sentiment",
],
)
# Execute team workflow - all agent interactions are traced
finance_team.print_response("Analyze Apple (AAPL) investment potential")Example: Custom Tracer Configuration
For advanced use cases with custom OpenTelemetry configuration:
import openlit
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.hackernews import HackerNewsTools
# Configure custom tracer provider
trace_provider = TracerProvider()
trace_provider.add_span_processor(
SimpleSpanProcessor(
OTLPSpanExporter(endpoint="http://127.0.0.1:4318/v1/traces")
)
)
trace.set_tracer_provider(trace_provider)
# Initialize OpenLIT - it auto-detects and reuses the tracer provider configured above
openlit.init(
disable_batch=True
)
# Create and configure the agent
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
tools=[HackerNewsTools()],
markdown=True,
)
# Use the agent
agent.print_response("What is currently trending on HackerNews?")OpenLIT Dashboard Features
Once your agents are instrumented, you can access the OpenLIT dashboard to:
- View Traces: Visualize complete execution flows including agent runs, tool calls, and LLM requests
- Monitor Performance: Track latency, token usage, and throughput metrics
- Analyze Costs: Monitor API costs across different models and providers
- Track Errors: Identify and debug exceptions with detailed stack traces
- Compare Models: Evaluate different LLM providers based on performance and cost
Configuration Options
The openlit.init() function accepts several parameters:
openlit.init(
otlp_endpoint="http://127.0.0.1:4318", # OTLP collector endpoint
disable_batch=False, # Disable batch span processing
environment="production", # Environment name for filtering
application_name="my-agent", # Application identifier
)CLI-Based Instrumentation
For true zero-code instrumentation, you can use the openlit-instrument CLI command to run your application without modifying any code:
openlit-instrument \
--service_name my-ai-app \
--environment production \
--otlp_endpoint http://127.0.0.1:4318 \
python your_app.pyThis approach is particularly useful for:
- Adding observability to existing applications without code changes
- CI/CD pipelines where you want to instrument automatically
- Testing observability before committing to code modifications
Notes
- Automatic Instrumentation: OpenLIT automatically instruments supported LLM providers (OpenAI, Anthropic, etc.) and frameworks
- Zero Code Changes: Use either
openlit.init()in your code or theopenlit-instrumentCLI to trace all LLM calls without modifications - OpenTelemetry Native: OpenLIT uses standard OpenTelemetry protocols, ensuring compatibility with other observability tools
- Open-Source & Self-Hosted: OpenLIT is fully open-source and runs on your own infrastructure for complete data privacy and control
Integration with Other Platforms
OpenLIT can export traces to other observability platforms like Grafana Cloud, New Relic and more. See the Langfuse integration guide for an example of using OpenLIT with Langfuse.