AutoGen Observability & Monitoring with OpenTelemetry Microsoft and SigNoz have released a guide for setting up observability and monitoring for AutoGen AI applications using OpenTelemetry, enabling developers to export logs, traces, and metrics to SigNoz for real-time visibility into latency, error rates, and usage trends. The integration allows users to instrument AutoGen workflows with no-code auto-instrumentation or manual configuration, capturing request/response details and system-level metrics to debug issues, optimize performance, and improve reliability. Overview This guide walks you through setting up observability and monitoring for AutoGen using OpenTelemetry https://opentelemetry.io/ and exporting logs, traces, and metrics to SigNoz. With this integration, you can observe various models performance, capture request/response details, and track system-level metrics in SigNoz, giving you real-time visibility into latency, error rates, and usage trends for your AutoGen applications. Instrumenting AutoGen in your AI applications with telemetry ensures full observability across your AI workflows, making it easier to debug issues, optimize performance, and understand user interactions. By leveraging SigNoz, you can analyze correlated traces, logs, and metrics in unified dashboards, configure alerts, and gain actionable insights to continuously improve reliability, responsiveness, and user experience. Prerequisites - A SigNoz Cloud account https://signoz.io/teams/ with an active ingestion key - Internet access to send telemetry data to SigNoz Cloud - Python 3.10+ with AutoGen installed pip install autogen-agentchat autogen-ext autogen-core - For Python: pip installed for managing Python packages and optional but recommended a Python virtual environment to isolate dependencies Monitoring AutoGen For more detailed info on tracing your AutoGen applications click here https://microsoft.github.io/autogen/stable//user-guide/core-user-guide/framework/telemetry.html . For logging, click here https://microsoft.github.io/autogen/stable//user-guide/core-user-guide/framework/logging.html . No-code auto-instrumentation is recommended for quick setup with minimal code changes. It's ideal when you want to get observability up and running without modifying your application code and are leveraging standard instrumentor libraries. Step 1: Install the necessary packages in your Python environment. pip install \ opentelemetry-api \ opentelemetry-distro \ opentelemetry-exporter-otlp \ httpx \ "autogen-agentchat" \ "autogen-ext openai " \ "autogen-core" Step 2: Add Automatic Instrumentation opentelemetry-bootstrap --action=install Step 3: Instrument your AutoGen application For Traces: Configure AutoGen to use OpenTelemetry tracing by passing the tracer provider to the runtime: python from opentelemetry import trace from autogen core import SingleThreadedAgentRuntime tracer provider = trace.get tracer provider single threaded runtime = SingleThreadedAgentRuntime tracer provider=tracer provider For Logs: Configure AutoGen logging to capture trace logs: python import logging from autogen core import TRACE LOGGER NAME logging.basicConfig level=logging.WARNING logger = logging.getLogger TRACE LOGGER NAME logger.addHandler logging.StreamHandler logger.setLevel logging.DEBUG πŸ“Œ Note: Ensure this is configured before initializing your AutoGen agents to properly instrument your application Step 4: Run an example python from autogen agentchat.agents import AssistantAgent from autogen agentchat.ui import Console from autogen ext.models.openai import OpenAIChatCompletionClient from opentelemetry import trace from autogen core import SingleThreadedAgentRuntime, TRACE LOGGER NAME import logging import asyncio logging.basicConfig level=logging.WARNING logger = logging.getLogger TRACE LOGGER NAME logger.addHandler logging.StreamHandler logger.setLevel logging.DEBUG Get the tracer provider from your application tracer provider = trace.get tracer provider for single threaded runtime single threaded runtime = SingleThreadedAgentRuntime tracer provider=tracer provider Define a model client. model client = OpenAIChatCompletionClient model="gpt-4o-mini" Define a simple function tool that the agent can use. For this example, we use a fake weather tool for demonstration purposes. async def get weather city: str - str: """Get the weather for a given city.""" return f"The weather in {city} is 73 degrees and Sunny." Define an AssistantAgent with the model, tool, system message, and reflection enabled. The system message instructs the agent via natural language. agent = AssistantAgent name="weather agent", model client=model client, tools= get weather , system message="You are a helpful assistant.", reflect on tool use=True, model client stream=True, Enable streaming tokens from the model client. Run the agent and stream the messages to the console. async def main - None: await Console agent.run stream task="What is the weather in New York?" Close the connection to the model client. await model client.close asyncio.run main πŸ“Œ Note: Before running this code, ensure that you have set the environment variable OPENAI API KEY with your generated API key. Step 5: Run your application with auto-instrumentation OTEL RESOURCE ATTRIBUTES="service.name=