Registry / observability / opentelemetry-instrumentation

opentelemetry-instrumentation

JSON →
library0.65b0pypypi✓ verified 24d ago

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.

pip install opentelemetry-instrumentation
INSTALL
IMPORT
SIG · OPENTELEMETRY-INST
O
opentelemetry-instrumentation
observabilitypythonv0.65b0
Install
2.8s avg
Import
418ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.65b0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.434s · 22.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.8s · import 0.402s · 23MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BaseInstrumentor
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
Ensure correct import path to access the BaseInstrumentor class.

Quickstart guide to instrumenting ASGI and WSGI applications using OpenTelemetry.

import os from opentelemetry.instrumentation.asgi import AsgiInstrumentor from opentelemetry.instrumentation.wsgi import WSGIInstrumentor # Initialize instrumentation AsgiInstrumentor().instrument() WSGIInstrumentor().instrument() # Your application code here # For example, using ASGI: # app = ... # app.run() # For WSGI: # from wsgi_app import app # app.run()
opentelemetry-instrument --version
Debug
Known issues
breakingThe 'instrumentation' module has been refactored; ensure imports are updated accordingly.
fix
Update import statements to reflect the new module structure.
affects: 0.60b0 and later
gotchaAutomatic instrumentation may not support all third-party libraries out of the box.
fix
Manually instrument unsupported libraries by importing the appropriate instrumentor classes and calling their 'instrument()' methods.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'opentelemetry.instrumentation'
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.
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.
ImportError: cannot import name '_SUPPRESS_HTTP_INSTRUMENTATION_KEY' from 'opentelemetry.context'
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.
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).
AttributeError: 'ProxyTracerProvider' object has no attribute 'resource'
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.
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.
No telemetry is produced
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.
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.
Upgrade
Version history
0.65b0latest on PyPI · released Jul 16, 2026
Audit
Dependencies
opentelemetry-apirequiredProvides the OpenTelemetry API for Python, essential for instrumentation.
opentelemetry-sdkrequiredProvides the OpenTelemetry SDK for Python, necessary for processing and exporting telemetry data.
Agent activity
17 hits · last 30 days
node
12
OpenAI (training)
2
Resources
opentelemetry-instrumentation — pip install opentelemetry-instrumentation · libregistry