{"id":4153,"library":"opentelemetry-instrumentation-agno","title":"OpenTelemetry Agno Instrumentation","description":"This library provides OpenTelemetry auto-instrumentation for Agno agents, enabling detailed tracing of AI applications. It's part of the OpenInference project, ensuring compatibility with OpenTelemetry collectors and observability backends like Arize Phoenix and Langfuse. Currently at version 0.58.0, it follows a rapid release cadence, with multiple minor and patch releases occurring monthly to incorporate new features and align with evolving OpenTelemetry semantic conventions.","status":"active","version":"0.58.0","language":"en","source_language":"en","source_url":"https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-agno","tags":["opentelemetry","instrumentation","agno","llm","ai","observability","tracing","agent","openinference"],"install":[{"cmd":"pip install opentelemetry-instrumentation-agno agno opentelemetry-sdk opentelemetry-exporter-otlp-proto-http","lang":"bash","label":"Install core, Agno, and OTLP HTTP exporter"}],"dependencies":[{"reason":"The core AI agent library being instrumented.","package":"agno","optional":false},{"reason":"OpenTelemetry API for Python.","package":"opentelemetry-api","optional":false},{"reason":"OpenTelemetry SDK for Python, required for application instrumentation.","package":"opentelemetry-sdk","optional":false},{"reason":"Provides semantic conventions for tracing LLM applications, used by OpenInference instrumentations.","package":"openinference-semantic-conventions","optional":false},{"reason":"Standard OpenTelemetry semantic conventions.","package":"opentelemetry-semantic-conventions","optional":false},{"reason":"Required Python version.","package":"python","version":">=3.10, <4","optional":false}],"imports":[{"note":"The primary class to enable Agno instrumentation.","symbol":"AgnoInstrumentor","correct":"from openinference.instrumentation.agno import AgnoInstrumentor"}],"quickstart":{"code":"import os\nfrom opentelemetry import trace\nfrom opentelemetry.sdk.resources import Resource\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import SimpleSpanProcessor\nfrom opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter\n\nfrom openinference.instrumentation.agno import AgnoInstrumentor\n\n# Agno related imports for the example\nfrom agno.agent import Agent\nfrom agno.models.openai import OpenAIChat\nfrom agno.tools.duckduckgo import DuckDuckGoTools\n\n# Configure OpenTelemetry TracerProvider\nresource = Resource.create({\"service.name\": \"agno-agent-app\"})\nprovider = TracerProvider(resource=resource)\n\n# Export spans to an OTLP collector (e.g., SigNoz, Jaeger, Arize Phoenix)\n# Replace with your actual OTLP endpoint if not using default localhost\notlp_endpoint = os.environ.get(\"OTEL_EXPORTER_OTLP_ENDPOINT\", \"http://localhost:4318/v1/traces\")\nspan_processor = SimpleSpanProcessor(OTLPSpanExporter(endpoint=otlp_endpoint))\nprovider.add_span_processor(span_processor)\n\n# Set the global TracerProvider\ntrace.set_tracer_provider(provider)\n\n# Initialize Agno instrumentation\nAgnoInstrumentor().instrument()\n\n# Example Agno Agent application\nprint(\"Agno Agent started...\")\nagent = Agent(\n    model=OpenAIChat(id=os.environ.get(\"OPENAI_MODEL_ID\", \"gpt-4o-mini\")),\n    tools=[DuckDuckGoTools()],\n    markdown=True,\n    debug_mode=True,\n)\n\nresponse = agent.print_response(\"What is the current weather in London?\")\nprint(f\"Agent Response: {response}\")\n\nprint(\"Agno Agent finished. Check your OTLP collector for traces.\")\n\n# In a real application, you might want to ensure all spans are exported\n# before the application exits. For this simple example, we rely on\n# the SimpleSpanProcessor flushing on shutdown. For production, consider BatchSpanProcessor.\nprovider.shutdown()\n","lang":"python","description":"This quickstart demonstrates how to set up OpenTelemetry to automatically instrument an Agno agent application. It configures a `TracerProvider` with an `OTLPSpanExporter` to send traces to an OpenTelemetry collector and then initializes the `AgnoInstrumentor` before running a simple Agno agent. Ensure your OpenTelemetry collector is running and accessible at the configured OTLP endpoint."},"warnings":[{"fix":"Ensure `trace.set_tracer_provider(provider)` is called early in your application's lifecycle, prior to importing or initializing any Agno-related code or calling `AgnoInstrumentor().instrument()`.","message":"OpenTelemetry SDK must be initialized before AgnoInstrumentation. If `trace.set_tracer_provider()` is called after `AgnoInstrumentor().instrument()` or after Agno components are imported, no traces will be emitted as API calls will use a no-op implementation.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Monitor OpenTelemetry semantic convention releases and your instrumentation library's updates. Consider using the `OTEL_SEMCONV_STABILITY_OPT_IN` environment variable (e.g., `OTEL_SEMCONV_STABILITY_OPT_IN=http/dup` for HTTP) to manage compatibility during migration, and update your dashboards/queries accordingly. For Agno-specific attributes, refer to the `openinference-semantic-conventions` documentation.","message":"The OpenTelemetry semantic conventions, particularly for Generative AI (GenAI), are actively evolving. Recent versions of `opentelemetry-instrumentation-agno` frequently update to align with new OpenTelemetry GenAI semantic conventions (e.g., changes to `gen_ai.tool.name`). This can lead to breaking changes in attribute names or structures if your observability backend or custom analysis tools rely on older semantic conventions.","severity":"breaking","affected_versions":"0.53.0 and newer (due to active updates)"},{"fix":"Ensure `agno` is included in your project dependencies and installed in the environment where your application runs (e.g., `pip install agno`).","message":"This instrumentation library only works if the `agno` package is installed alongside it. Without `agno` present, the instrumentation will not find the target library to patch, and no Agno-specific traces will be generated.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}