Name | opentelemetry-instrumentation-urllib JSON |
Version |
0.56b0
JSON |
| download |
home_page | None |
Summary | OpenTelemetry urllib instrumentation |
upload_time | 2025-07-11 12:26:52 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
|
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>`_
Raw data
{
"_id": null,
"home_page": null,
"name": "opentelemetry-instrumentation-urllib",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "OpenTelemetry Authors <cncf-opentelemetry-contributors@lists.cncf.io>",
"download_url": "https://files.pythonhosted.org/packages/10/09/6e8932c791eb6590ded44e26cd7e0c281e224798dcd6e2107045c1c93fed/opentelemetry_instrumentation_urllib-0.56b0.tar.gz",
"platform": null,
"description": "OpenTelemetry urllib Instrumentation\n====================================\n\n|pypi|\n\n.. |pypi| image:: https://badge.fury.io/py/opentelemetry-instrumentation-urllib.svg\n :target: https://pypi.org/project/opentelemetry-instrumentation-urllib/\n\nThis library allows tracing HTTP requests made by the\n`urllib <https://docs.python.org/3/library/urllib.html>`_ library.\n\nInstallation\n------------\n\n::\n\n pip install opentelemetry-instrumentation-urllib\n\nConfiguration\n-------------\n\nRequest/Response hooks\n**********************\n\nThe urllib instrumentation supports extending tracing behavior with the help of\nrequest and response hooks. These are functions that are called back by the instrumentation\nright after a Span is created for a request and right before the span is finished processing a response respectively.\nThe hooks can be configured as follows:\n\n.. code:: python\n\n from opentelemetry.instrumentation.urllib import URLLibInstrumentor\n\n # `request_obj` is an instance of urllib.request.Request\n def request_hook(span, request_obj):\n pass\n\n # `request_obj` is an instance of urllib.request.Request\n # `response` is an instance of http.client.HTTPResponse\n def response_hook(span, request_obj, response)\n pass\n\n URLLibInstrumentor().instrument(\n request_hook=request_hook, response_hook=response_hook\n )\n\nExclude lists\n*************\n\nTo exclude certain URLs from being tracked, set the environment variable ``OTEL_PYTHON_URLLIB_EXCLUDED_URLS``\n(or ``OTEL_PYTHON_EXCLUDED_URLS`` as fallback) with comma delimited regexes representing which URLs to exclude.\n\nFor example,\n\n::\n\n export OTEL_PYTHON_URLLIB_EXCLUDED_URLS=\"client/.*/info,healthcheck\"\n\nwill exclude requests such as ``https://site/client/123/info`` and ``https://site/xyz/healthcheck``.\n\nReferences\n----------\n\n* `OpenTelemetry urllib Instrumentation <https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/urllib/urllib.html>`_\n* `OpenTelemetry Project <https://opentelemetry.io/>`_\n* `OpenTelemetry Python Examples <https://github.com/open-telemetry/opentelemetry-python/tree/main/docs/examples>`_\n",
"bugtrack_url": null,
"license": null,
"summary": "OpenTelemetry urllib instrumentation",
"version": "0.56b0",
"project_urls": {
"Homepage": "https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation/opentelemetry-instrumentation-urllib",
"Repository": "https://github.com/open-telemetry/opentelemetry-python-contrib"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "c7789723d95c34793ef0e28d347b182446d5d932132a7d108666ffd822fd612c",
"md5": "9e3af77ef254075604bbe1a9037d112b",
"sha256": "4cada385bcb61d920c53ded43b171a0554f44034ffa82b01eb73988a1a96422b"
},
"downloads": -1,
"filename": "opentelemetry_instrumentation_urllib-0.56b0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9e3af77ef254075604bbe1a9037d112b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 12671,
"upload_time": "2025-07-11T12:26:10",
"upload_time_iso_8601": "2025-07-11T12:26:10.777903Z",
"url": "https://files.pythonhosted.org/packages/c7/78/9723d95c34793ef0e28d347b182446d5d932132a7d108666ffd822fd612c/opentelemetry_instrumentation_urllib-0.56b0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "10096e8932c791eb6590ded44e26cd7e0c281e224798dcd6e2107045c1c93fed",
"md5": "3267dafe259adcf50c4be7cdd7a03945",
"sha256": "127401fa17f84ec2f9f0b72d0c968ecb50a6c86651a5d69e6a8cf733b881d328"
},
"downloads": -1,
"filename": "opentelemetry_instrumentation_urllib-0.56b0.tar.gz",
"has_sig": false,
"md5_digest": "3267dafe259adcf50c4be7cdd7a03945",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 13932,
"upload_time": "2025-07-11T12:26:52",
"upload_time_iso_8601": "2025-07-11T12:26:52.145704Z",
"url": "https://files.pythonhosted.org/packages/10/09/6e8932c791eb6590ded44e26cd7e0c281e224798dcd6e2107045c1c93fed/opentelemetry_instrumentation_urllib-0.56b0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-11 12:26:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "open-telemetry",
"github_project": "opentelemetry-python-contrib",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"tox": true,
"lcname": "opentelemetry-instrumentation-urllib"
}