Prerequisites

  1. Install Dependencies
    pip install agno openai langwatch openinference-instrumentation-agno
    
  2. Create a Langwatch Account
    • Sign up or log in to your LangWatch dashboard.
    • Obtain your API key from your project settings.
  3. Set Environment Variables
    export LANGWATCH_API_KEY=your-langwatch-api-key
    export OPENAI_API_KEY=your-openai-key
    

Sending Traces to LangWatch

This example demonstrates how to instrument your Agno agent and send traces to LangWatch
import langwatch
import os

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.yfinance import YFinanceTools
from openinference.instrumentation.agno import AgnoInstrumentor

# Initialize LangWatch and instrument Agno
langwatch.setup(
    instrumentors=[AgnoInstrumentor()]
)

agent = Agent(
    name="Stock Price Agent",
    model=OpenAIChat(id="gpt-4o-mini"),
    tools=[YFinanceTools()],
    instructions="You are a stock price agent. Answer questions in the style of a stock analyst.",
    debug_mode=True,
)

agent.print_response("What is the current price of Tesla?")

Notes

  • No OpenTelemetry Setup Needed: You do not need to set any OpenTelemetry environment variables or configure exporters manually—langwatch.setup() handles everything.
  • Troubleshooting: If you see no traces in LangWatch, ensure your LANGWATCH_API_KEY is set and that the instrumentor is included in langwatch.setup().
  • For advanced configuration (custom attributes, endpoint, etc.), see the LangWatch Python integration guide.
By following these steps, you can effectively integrate Agno with LangWatch, enabling comprehensive observability and monitoring of your AI agents.