Skip to main content
Pre-release

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

pypi

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

Installation

pip install opentelemetry-instrumentation-urllib

Configuration

Request/Response hooks

The urllib instrumentation supports extending tracing behavior with the help of request and response hooks. These are functions that are called back by the instrumentation right after a Span is created for a request and right before the span is finished processing a response respectively. The hooks can be configured as follows:

from opentelemetry.instrumentation.urllib import URLLibInstrumentor

# `request_obj` is an instance of urllib.request.Request
def request_hook(span, request_obj):
    pass

# `request_obj` is an instance of urllib.request.Request
# `response` is an instance of http.client.HTTPResponse
def response_hook(span, request_obj, response):
    pass

URLLibInstrumentor().instrument(
    request_hook=request_hook, response_hook=response_hook
)

Exclude lists

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

For example,

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

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

References

Release files for opentelemetry-instrumentation-urllib 0.65b0

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-urllib 0.65b0
File Size Uploaded
opentelemetry_instrumentation_urllib-0.65b0.tar.gz 16.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for opentelemetry-instrumentation-urllib 0.65b0
File Interpreter ABI Platform
opentelemetry_instrumentation_urllib-0.65b0-py3-none-any.whl Python 3 none any Details

Total release size: 29.8 kB

Release files / opentelemetry_instrumentation_urllib-0.65b0.tar.gz

Download URL opentelemetry_instrumentation_urllib-0.65b0.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8e7d1ada475296136815763bdabe683460969d09d93752c4f11ef0175598151c
BLAKE2b-256 checksum
How to use checksums
a3d48379f5b5967eee7c94ab9125991e76d16869d788afdddce093be1997db23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Release files / opentelemetry_instrumentation_urllib-0.65b0-py3-none-any.whl

Download URL opentelemetry_instrumentation_urllib-0.65b0-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df1b79e50d6d59f4248acc659bbed0ada8ccc8a028ee915d3fdeaf9140672b87
BLAKE2b-256 checksum
How to use checksums
cc379b8a61d5493865319a27a0de06eaa2f3da4f8df24cc2903b32eb901db227
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Release history Release notifications | RSS feed

This release

0.65b0 This release

2 release files

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