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


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

File details

Details for the file opentelemetry_instrumentation_urllib-0.49b2.tar.gz.

File metadata

File hashes

Hashes for opentelemetry_instrumentation_urllib-0.49b2.tar.gz
Algorithm Hash digest
SHA256 a148c073de6a1bbaf3ca423e639840cd2aa554eb0dda95077c111e46ea91d8ca
MD5 d2980b10c06804dbad9e04684c43d1d6
BLAKE2b-256 90f0295d399e0bdc89fe7ca36cccf3d09d274f7c97b8d444441e83704df8ce49

See more details on using hashes here.

File details

Details for the file opentelemetry_instrumentation_urllib-0.49b2-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_instrumentation_urllib-0.49b2-py3-none-any.whl
Algorithm Hash digest
SHA256 30e8eb408a93e0b09bb67e37c8b2c074ea3d55613467be6dc4be08f034a0d3e2
MD5 8ab5a746a56c069f6acafa6416f5caca
BLAKE2b-256 60fe036a2eebb7447683841473c8ac5e0fc286449b759f4567c68dfbffe74fdb

See more details on using hashes here.

Supported by

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