Qwen Observability & Monitoring with OpenTelemetry Alibaba Cloud has released a guide for setting up observability and monitoring for its Qwen large language model using OpenTelemetry and SigNoz. The integration enables developers to export traces, logs, and metrics from Qwen applications into unified dashboards for analyzing AI and LLM workflow performance. The setup supports both SigNoz Cloud and self-hosted instances, with automatic instrumentation available for Python environments. Overview This guide walks you through setting up observability and monitoring for Qwen using OpenTelemetry https://opentelemetry.io/ and exporting traces, logs, and metrics to SigNoz. With this integration, you can observe and track various metrics for your Qwen applications and LLM usage. Monitoring Qwen in your AI applications with telemetry ensures full observability across your AI and LLM workflows. 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 or Self Hosted SigNoz instance https://signoz.io/docs/install/self-host/ - For Python: pip installed for managing Python packages - An Alibaba Cloud Account, Model Studio account, and API key. You can get the API key from Model Studio platform https://modelstudio.console.alibabacloud.com/?tab=playground /api-key Monitoring Qwen For more information on getting started with Qwen in your Python environment, refer to the Qwen quickstart guide https://www.alibabacloud.com/help/en/model-studio/first-api-call-to-qwen . 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-distro \ opentelemetry-exporter-otlp \ httpx \ opentelemetry-instrumentation-httpx \ opentelemetry-instrumentation-system-metrics \ openai \ opentelemetry-instrumentation-openai-v2 Step 2: Add Automatic Instrumentation opentelemetry-bootstrap --action=install Step 3: Configure logging level To ensure logs are properly captured and exported, configure the root logger to emit logs at the DEBUG level or higher: python import logging logging.getLogger .setLevel logging.DEBUG logging.getLogger "httpx" .setLevel logging.DEBUG This sets the minimum log level for the root logger to DEBUG, which ensures that logger.debug calls and higher severity logs INFO, WARNING, ERROR, CRITICAL are captured by the OpenTelemetry logging auto-instrumentation and sent to SigNoz. Step 4: Create an example Qwen application python import os from openai import OpenAI import logging logging.getLogger .setLevel logging.DEBUG logging.getLogger "httpx" .setLevel logging.DEBUG try: client = OpenAI If the environment variable is not configured, replace with: api key="sk-xxx" api key=os.getenv "DASHSCOPE API KEY" , base url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1", completion = client.chat.completions.create model='qwen-turbo', messages= {'role': 'system', 'content': 'You are a helpful assistant.'}, {'role': 'user', 'content': 'What is SigNoz?'}, print completion.choices 0 .message.content except Exception as e: print f"Error message: {e}" print "See: https://www.alibabacloud.com/help/model-studio/developer-reference/error-code" Before running this code, ensure that you have set the environment variable DASHSCOPE API KEY with your generated Qwen API key from Model Studio . Step 5: Run your application with auto-instrumentation Run your application with the following environment variables set. This configures OpenTelemetry to export traces, logs, and metrics to SigNoz Cloud and enables automatic log correlation: OTEL RESOURCE ATTRIBUTES="service.name=