Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

OpenTelemetry Requests Instrumentation

pypi

This library allows tracing HTTP requests made by the requests library.

Installation

pip install opentelemetry-instrumentation-requests

Configuration

Exclude lists

To exclude certain URLs from being tracked, set the environment variable OTEL_PYTHON_REQUESTS_EXCLUDED_URLS (or OTEL_PYTHON_EXCLUDED_URLS as fallback) with comma delimited regexes representing which URLs to exclude.

For example,

export OTEL_PYTHON_REQUESTS_EXCLUDED_URLS="client/.*/info,healthcheck"

will exclude requests such as https://site/client/123/info and https://site/xyz/healthcheck.

Request/Response hooks

RequestsInstrumentor().instrument accepts optional request_hook and response_hook callbacks. The request hook receives the span and the live requests.PreparedRequest after the span is created and before OpenTelemetry injects propagation headers. Because this is the same request object that requests sends, mutations made by the hook can change the outbound request.

Propagation runs after the request hook, so values written by the configured propagator can replace values written by the hook. Avoid copying inbound headers wholesale into an outbound request; preserve headers owned by the application or connector unless the hook intentionally owns them.

The response hook receives the span, the prepared request, and the requests.Response before the span is finished.

For example:

def request_hook(span, request):
    request.headers["X-Request-Source"] = "example"

RequestsInstrumentor().instrument(request_hook=request_hook)

References

Metadata

Release files for opentelemetry-instrumentation-requests 0.67b0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opentelemetry-instrumentation-requests 0.67b0
File Size Uploaded Provenance Actions
opentelemetry_instrumentation_requests-0.67b0.tar.gz 18.6 kB Without provenance Details for opentelemetry_instrumentation_requests-0.67b0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for opentelemetry-instrumentation-requests 0.67b0
File Interpreter ABI Platform Actions
opentelemetry_instrumentation_requests-0.67b0-py3-none-any.whl Python 3 none any Details for opentelemetry_instrumentation_requests-0.67b0-py3-none-any.whl

Total release size: 32.6 kB

Release files / opentelemetry_instrumentation_requests-0.67b0.tar.gz

Download URL opentelemetry_instrumentation_requests-0.67b0.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
552a51485dc3560fd718276d0b024d4f09a20423ac45736e0c10e90c9956d3d1
BLAKE2b-256 checksum
How to use checksums
970149c9c81e60a7ee448e4709a0a1a9e810ce4077b02b9858cf1393a2b56e61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

Release files / opentelemetry_instrumentation_requests-0.67b0-py3-none-any.whl

Download URL opentelemetry_instrumentation_requests-0.67b0-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f258000ad80ee6137cde72618eeafa2a0012c40b133ebbf66d2fd447975c2440
BLAKE2b-256 checksum
How to use checksums
8c0c40971af5e77351105fd76bccd2d09854aa2b840b34652980ba8f9317224c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

Security for opentelemetry-instrumentation-requests 0.67b0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page