This release is a pre-release and may not be stable for production use.
OpenTelemetry urllib Instrumentation
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.66b0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| opentelemetry_instrumentation_urllib-0.66b0.tar.gz | 16.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| opentelemetry_instrumentation_urllib-0.66b0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.7 kB
Release files / opentelemetry_instrumentation_urllib-0.66b0.tar.gz
| Download URL | opentelemetry_instrumentation_urllib-0.66b0.tar.gz |
|---|---|
| Size | 16.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a919d8014dcf0065ad42ce5c78dd158c76c7342929f451d726462f7ffa68e367
|
|
BLAKE2b-256 checksum How to use checksums |
87e945d2324131c894ea5e116baac679a5948cc413c5484bc4b325ab48507358
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Release files / opentelemetry_instrumentation_urllib-0.66b0-py3-none-any.whl
| Download URL | opentelemetry_instrumentation_urllib-0.66b0-py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3eb6d2b9b28bb51188d77092a58eac2ab04852d244acb51333bdf42b0e933c68
|
|
BLAKE2b-256 checksum How to use checksums |
861fb147a9d0dddf5f80413262eb4c226eccc60c4cc2f6781cb6433c41bd4f97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|