{"id":409,"library":"opentelemetry-instrumentation","title":"OpenTelemetry Instrumentation for Python","description":"Provides automatic instrumentation tools for OpenTelemetry in Python, enabling seamless tracing and monitoring of Python applications. Current version: 0.61b0. Release cadence: Regular updates with new features and support for additional Python versions.","status":"active","version":"0.61b0","language":"python","source_language":"en","source_url":"https://github.com/open-telemetry/opentelemetry-python-contrib","tags":["OpenTelemetry","Python","Instrumentation","Tracing","Monitoring"],"install":[{"cmd":"pip install opentelemetry-instrumentation","lang":"bash","label":"Install OpenTelemetry Instrumentation"}],"dependencies":[{"reason":"Provides the OpenTelemetry API for Python, essential for instrumentation.","package":"opentelemetry-api"},{"reason":"Provides the OpenTelemetry SDK for Python, necessary for processing and exporting telemetry data.","package":"opentelemetry-sdk"}],"imports":[{"note":"Ensure correct import path to access the BaseInstrumentor class.","symbol":"BaseInstrumentor","correct":"from opentelemetry.instrumentation.instrumentor import BaseInstrumentor"}],"quickstart":{"code":"import os\nfrom opentelemetry.instrumentation.asgi import AsgiInstrumentor\nfrom opentelemetry.instrumentation.wsgi import WSGIInstrumentor\n\n# Initialize instrumentation\nAsgiInstrumentor().instrument()\nWSGIInstrumentor().instrument()\n\n# Your application code here\n# For example, using ASGI:\n# app = ...\n# app.run()\n\n# For WSGI:\n# from wsgi_app import app\n# app.run()","lang":"python","description":"Quickstart guide to instrumenting ASGI and WSGI applications using OpenTelemetry."},"warnings":[{"fix":"Update import statements to reflect the new module structure.","message":"The 'instrumentation' module has been refactored; ensure imports are updated accordingly.","severity":"breaking","affected_versions":"0.60b0 and later"},{"fix":"Manually instrument unsupported libraries by importing the appropriate instrumentor classes and calling their 'instrument()' methods.","message":"Automatic instrumentation may not support all third-party libraries out of the box.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T13:38:56.610Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Install the necessary OpenTelemetry instrumentation packages using `pip install opentelemetry-instrumentation` and any specific instrumentation packages for your frameworks (e.g., `pip install opentelemetry-instrumentation-flask`). Always ensure your application is running in the correct Python environment where these packages are installed.","cause":"This error occurs when the core `opentelemetry-instrumentation` package or a specific instrumentation library (e.g., `opentelemetry-instrumentation-flask`) is not installed, or there is a mismatch in Python environments between where the package is installed and where the application is run.","error":"ModuleNotFoundError: No module named 'opentelemetry.instrumentation'"},{"fix":"Upgrade all related OpenTelemetry packages to compatible versions. The most reliable fix is often to update `opentelemetry-api`, `opentelemetry-sdk`, and all `opentelemetry-instrumentation-*` packages to their latest stable releases using `pip install --upgrade opentelemetry-api opentelemetry-sdk opentelemetry-instrumentation-requests` (and any other relevant instrumentation packages).","cause":"This issue typically arises from version incompatibilities between the `opentelemetry-api` package and specific `opentelemetry-instrumentation-*` packages, where an instrumentation package attempts to import a non-existent key from an older or incompatible API version.","error":"ImportError: cannot import name '_SUPPRESS_HTTP_INSTRUMENTATION_KEY' from 'opentelemetry.context'"},{"fix":"Ensure that the OpenTelemetry SDK, including the `TracerProvider` and a `Resource`, is fully configured and set as the global tracer provider *before* any instrumentors are initialized or any instrumented application code begins execution. If using programmatic instrumentation, place SDK initialization at the very top of your application's entry point.","cause":"This error indicates that the OpenTelemetry SDK and its tracing pipeline, including the `TracerProvider` and its associated `Resource`, have not been fully or correctly initialized before an instrumentation attempts to access these components.","error":"AttributeError: 'ProxyTracerProvider' object has no attribute 'resource'"},{"fix":"Verify that the OpenTelemetry SDK is initialized before any instrumented code runs. Add a `ConsoleExporter` to your pipeline for debugging purposes to confirm data generation locally. Check all relevant environment variables, such as `OTEL_EXPORTER_OTLP_ENDPOINT` and `OTEL_TRACES_EXPORTER`, for correct values. Ensure the OpenTelemetry Collector is running and network accessible at the configured endpoint.","cause":"This common symptom, rather than a specific error message, occurs when your application is instrumented, but no trace, metric, or log data appears in your backend. This can be due to incorrect SDK initialization order, misconfigured or missing exporters (e.g., OTLP exporter), network connectivity problems to the OpenTelemetry Collector, or incorrect environment variable settings for auto-instrumentation.","error":"No telemetry is produced"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.3,"mem_mb":7.8,"disk_size":"22.0M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.2,"mem_mb":7.8,"disk_size":"23M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.51,"mem_mb":9.1,"disk_size":"24.2M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.39,"mem_mb":9.1,"disk_size":"25M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.64,"mem_mb":11.3,"disk_size":"16.0M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.6,"mem_mb":11.3,"disk_size":"17M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.28,"mem_mb":7.1,"disk_size":"15.6M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.28,"mem_mb":7.1,"disk_size":"16M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.26,"mem_mb":7.8,"disk_size":"21.5M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.23,"mem_mb":7.8,"disk_size":"22M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}