{"library":"azure-monitor-opentelemetry","title":"Azure Monitor OpenTelemetry Distro for Python","description":"Microsoft Azure Monitor Opentelemetry Distro Client Library for Python (version 1.8.7) offers a \"one-stop-shop\" solution for instrumenting Python applications. It captures traces, metrics, and logs via OpenTelemetry instrumentations and reports them to Azure Monitor Application Insights. The library is actively maintained with frequent updates, though many underlying OpenTelemetry instrumentations are still in beta and may introduce breaking changes.","status":"active","version":"1.8.7","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/monitor/azure-monitor-opentelemetry","tags":["Azure","OpenTelemetry","Monitoring","Application Insights","Observability","Tracing","Metrics","Logging","Cloud"],"install":[{"cmd":"pip install azure-monitor-opentelemetry","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Automatically installed and used for exporting telemetry to Azure Monitor.","package":"azure-monitor-opentelemetry-exporter","optional":false},{"reason":"Automatically installed for HTTP/HTTPS request instrumentation.","package":"opentelemetry-instrumentation-requests","optional":true},{"reason":"Automatically installed for Django framework instrumentation.","package":"opentelemetry-instrumentation-django","optional":true},{"reason":"Automatically installed for Flask framework instrumentation.","package":"opentelemetry-instrumentation-flask","optional":true},{"reason":"Automatically installed for Psycopg2 (PostgreSQL) database instrumentation.","package":"opentelemetry-instrumentation-psycopg2","optional":true},{"reason":"Automatically installed for urllib library instrumentation.","package":"opentelemetry-instrumentation-urllib","optional":true},{"reason":"Automatically installed for urllib3 library instrumentation.","package":"opentelemetry-instrumentation-urllib3","optional":true},{"reason":"Automatically installed for Azure SDK tracing.","package":"azure-core-tracing-opentelemetry","optional":true}],"imports":[{"symbol":"configure_azure_monitor","correct":"from azure.monitor.opentelemetry import configure_azure_monitor"}],"quickstart":{"code":"import os\nfrom azure.monitor.opentelemetry import configure_azure_monitor\nfrom opentelemetry import trace\n\n# Set your Application Insights Connection String as an environment variable:\n# APPLICATIONINSIGHTS_CONNECTION_STRING=\"InstrumentationKey=YOUR_INSTRUMENTATION_KEY;IngestionEndpoint=https://YOUR_REGION.in.applicationinsights.azure.com/\"\n\n# One-line setup - reads connection string from the environment variable\n# APPLICATIONINSIGHTS_CONNECTION_STRING. Call this early in your application.\nconfigure_azure_monitor()\n\n# Get a tracer from OpenTelemetry\ntracer = trace.get_tracer(__name__)\n\n# Create a sample span\nwith tracer.start_as_current_span(\"my-example-span\"):\n    print(\"Hello from an OpenTelemetry-instrumented application!\")\n    # Simulate some work\n    import time\n    time.sleep(0.1)\n\nprint(\"Telemetry sent to Azure Monitor (if connection string is configured).\")","lang":"python","description":"This quickstart demonstrates how to initialize the Azure Monitor OpenTelemetry Distro. Ensure the `APPLICATIONINSIGHTS_CONNECTION_STRING` environment variable is set with your Azure Application Insights connection string. The `configure_azure_monitor()` function automatically sets up the necessary OpenTelemetry components. A simple custom span is created to illustrate basic tracing."},"warnings":[{"fix":"Review the official migration guide on Microsoft Learn to adapt your code to OpenTelemetry-based APIs.","message":"Migration from older Application Insights SDKs (2.x) to `azure-monitor-opentelemetry` requires significant code changes, as most 2.x APIs are not supported and need to be updated to OpenTelemetry-based APIs.","severity":"breaking","affected_versions":"All versions when migrating from Application Insights SDK 2.x"},{"fix":"Monitor release notes and be prepared for potential breaking changes in minor or patch versions, especially when OpenTelemetry specifications evolve.","message":"Many OpenTelemetry instrumentations bundled with this distro are currently in a beta state, meaning they are not stable and may introduce breaking changes in future releases.","severity":"breaking","affected_versions":"All current versions (1.x.x)"},{"fix":"Place `configure_azure_monitor()` at the very beginning of your application's entry point script.","message":"The `configure_azure_monitor()` function must be called early in your application's lifecycle, preferably before importing other instrumented libraries, to ensure all telemetry is captured correctly and avoid potential data loss.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Disable one of the logging instrumentations to avoid duplicate telemetry. Refer to troubleshooting guides for specific configurations.","message":"Enabling both native logging instrumentation in Azure Functions and `azure-monitor-opentelemetry` logging instrumentation within the distribution can lead to duplicate trace logs in Application Insights.","severity":"gotcha","affected_versions":"All versions when used in Azure Functions"},{"fix":"Check for updates to the library or OpenTelemetry instrumentations. Manually add these attributes if critical for your analysis.","message":"Dependency telemetry might occasionally be missing the 'operation name' or 'device model', which can adversely affect performance analysis, filtering, and device cohort analysis in Application Insights.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-06T00:00:00.000Z","next_check":"2026-07-05T00:00:00.000Z"}