opentelemetry-instrumentation-urllib

OpenTelemetry urllib instrumentation

62 个版本 Python >=3.10
安装
pip install opentelemetry-instrumentation-urllib
poetry add opentelemetry-instrumentation-urllib
pipenv install opentelemetry-instrumentation-urllib
conda install opentelemetry-instrumentation-urllib
描述

OpenTelemetry urllib Instrumentation

|pypi|

.. |pypi| image:: https://badge.fury.io/py/opentelemetry-instrumentation-urllib.svg :target: https://pypi.org/project/opentelemetry-instrumentation-urllib/

This library allows tracing HTTP requests made by the urllib <https://docs.python.org/3/library/urllib.html>_ 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:

.. code:: python

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

  • OpenTelemetry urllib Instrumentation <https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/urllib/urllib.html>_
  • OpenTelemetry Project <https://opentelemetry.io/>_
  • OpenTelemetry Python Examples <https://github.com/open-telemetry/opentelemetry-python/tree/main/docs/examples>_
版本列表
0.63b1 2026-05-21
0.63b0 2026-05-19
0.62b1 2026-04-24
0.62b0 2026-04-09
0.61b0 2026-03-04
0.60b1 2025-12-11
0.60b0 2025-12-03
0.59b0 2025-10-16
0.58b0 2025-09-11
0.57b0 2025-07-29
0.56b0 2025-07-11
0.55b1 2025-06-10
0.55b0 2025-06-04
0.54b1 2025-05-16
0.54b0 2025-05-09
0.53b1 2025-04-15
0.53b0 2025-04-10
0.52b1 2025-03-20
0.52b0 2025-03-12
0.51b0 2025-02-04
0.50b0 2024-12-11
0.49b2 2024-11-18
0.49b1 2024-11-08
0.49b0 2024-11-05
0.48b0 2024-08-28
0.47b0 2024-07-25
0.46b0 2024-05-31
0.45b0 2024-03-28
0.44b0 2024-02-23
0.43b0 2023-12-19
0.42b0 2023-11-08
0.41b0 2023-09-11
0.40b0 2023-07-13
0.39b0 2023-05-19
0.38b0 2023-03-22
0.37b0 2023-02-17
0.36b0 2022-12-09
0.35b0 2022-11-03
0.34b0 2022-09-27
0.33b0 2022-08-09
0.32b0 2022-07-04
0.31b0 2022-05-17
0.30b1 2022-04-21
0.30b0 2022-04-18
0.29b0 2022-03-11
0.28b1 2022-01-31
0.28b0 2022-01-26
0.27b0 2021-12-17
0.26b1 2021-11-11
0.25b2 2021-10-19
0.25b1 2021-10-18
0.25b0 2021-10-13
0.24b0 2021-08-26
0.23b2 2021-07-28
0.23b0 2021-07-21
0.22b0 2021-06-02
0.21b0 2021-05-12
0.20b0 2021-04-20
0.19b0 2021-03-26
0.18b1 2021-02-19
0.18b0 2021-02-16
0.17b0 2021-01-21