Skip to main content

OpenTelemetry urllib instrumentation

Project description

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

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file opentelemetry_instrumentation_urllib-0.62b0.tar.gz.

File metadata

File hashes

Hashes for opentelemetry_instrumentation_urllib-0.62b0.tar.gz
Algorithm Hash digest
SHA256 03cc3c605923d5e7baafcb9bd007637f8e2fa1ad3ef4bb2e3efcc05d3392c768
MD5 9c4d708451a534418f8a9d540629fd3b
BLAKE2b-256 18df6344dec54f81684e02cd1825bdae6fceb15e7cc4a9a887163fd82a92d0af

See more details on using hashes here.

File details

Details for the file opentelemetry_instrumentation_urllib-0.62b0-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_instrumentation_urllib-0.62b0-py3-none-any.whl
Algorithm Hash digest
SHA256 53d70c9234a288a3eeaa3709011d597b90e682c7c4ffdc2d03d1d54fe55fa948
MD5 d05fe2a25b7861341f4f1c7ae983da8e
BLAKE2b-256 9194565ee87a2d4da6bfa5d1338dee48d52e399fd4684c88a126e5c8f6df1090

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page