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

opentelemetry_instrumentation_urllib-0.63b0.tar.gz (16.7 kB view details)

Uploaded Source

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.63b0.tar.gz.

File metadata

File hashes

Hashes for opentelemetry_instrumentation_urllib-0.63b0.tar.gz
Algorithm Hash digest
SHA256 d77cb5260dd1bae3376d5b98d133e6b0880b5dcfdf38d93919e1c884d9b3bfbb
MD5 0b246bb211373f47a279177233afaf8d
BLAKE2b-256 dac5fd6714fe44bd5fd4fedf018d0f73b69b3af939fdebe2e6b83dfc7ba371c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opentelemetry_instrumentation_urllib-0.63b0-py3-none-any.whl
Algorithm Hash digest
SHA256 2da7d45f7869d9619100606f4907f2e34c527d660efaa92b7c3fde521b44fb6e
MD5 149369f8e3973902b2affaef732772a0
BLAKE2b-256 afb75580e2b19a3b1a45bea357b9f2d74f290e12788de9a8edd70da1b66413ef

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