Registry / observability / opentelemetry-instrumentation-requests

opentelemetry-instrumentation-requests

JSON →
library0.61b0pypypiunverified

Provides tracing capabilities for HTTP requests made using the 'requests' library. Current version: 0.61b0. Release cadence: beta releases with incremental improvements.

observabilityhttp-networkingawsgcpazure
pip install opentelemetry-instrumentation-requests
Install & Compatibility
Where this runs
tested against v0.63b1 · 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
glibc
py 3.10
3/5 runs
3/5 runs
py 3.11
3/5 runs
3/5 runs
py 3.12
3/5 runs
3/5 runs
py 3.13
3/5 runs
3/5 runs
py 3.9
3/5 runs
3/5 runs
Code
Verified usage

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

RequestsInstrumentor
from opentelemetry.instrumentation.requests import RequestsInstrumentor
from opentelemetry.instrumentation.requests import RequestsInstrumentor

This script sets up OpenTelemetry tracing, instruments the 'requests' library, and makes an HTTP GET request to 'https://api.example.com'.

import os from opentelemetry.instrumentation.requests import RequestsInstrumentor from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import BatchSpanProcessor from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter from opentelemetry.sdk.resources import Resource, SERVICE_NAME # Set up the OpenTelemetry SDK resource = Resource.create({SERVICE_NAME: 'my-service'}) provider = TracerProvider(resource=resource) provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter())) provider.register() # Instrument the 'requests' library RequestsInstrumentor().instrument() # Make an HTTP request import requests response = requests.get('https://api.example.com') print(response.status_code)
Debug
Known issues
breakingInstrumenting after importing 'requests' may result in incomplete tracing due to module caching.
fix
Ensure 'RequestsInstrumentor().instrument()' is called before importing 'requests'.
affects: all
gotchaSetting 'OTEL_PYTHON_REQUESTS_EXCLUDED_URLS' to exclude certain URLs may not work if the environment variable is not set correctly.
fix
Verify the environment variable is set with the correct regex patterns to exclude desired URLs.
affects: all
breakingThe 'requests' package is a direct dependency of opentelemetry-instrumentation-requests and must be installed.
fix
Install the 'requests' package using pip: 'pip install requests'.
affects: all
breakingThe 'requests' library is a required dependency for 'opentelemetry-instrumentation-requests' and must be installed. The absence of 'requests' will cause a `ModuleNotFoundError`.
fix
Install the 'requests' library using `pip install requests`.
affects: all
Upgrade
Version history
0.63b1latest on PyPI
Audit
Dependencies
requestsrequiredRequired for HTTP request instrumentation
Agent activity
76 hits · last 30 days
node
10
ahrefsbot
3
Amazon
1
seranking-bot
1
Resources