Name | opentelemetry-instrumentation-urllib JSON |
Version |
0.58b0
JSON |
| download |
home_page | None |
Summary | OpenTelemetry urllib instrumentation |
upload_time | 2025-09-11 11:42:58 |
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/84/94/48171907cb9ced5bdc5be18f8cc8a8234bb2ec695f20c69f1330b336f2fb/opentelemetry_instrumentation_urllib-0.58b0.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.58b0",
"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": "576637edce21a14b6a983577d7aea95fee3581e80f9b4a272f514726e5041104",
"md5": "8ac8af37d9b5e69db95a5267dba701af",
"sha256": "63ad8a304a299bcb39224ecedc718a391404c8f2d4cc5755edfb5e49904e7b27"
},
"downloads": -1,
"filename": "opentelemetry_instrumentation_urllib-0.58b0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8ac8af37d9b5e69db95a5267dba701af",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 12674,
"upload_time": "2025-09-11T11:42:02",
"upload_time_iso_8601": "2025-09-11T11:42:02.776835Z",
"url": "https://files.pythonhosted.org/packages/57/66/37edce21a14b6a983577d7aea95fee3581e80f9b4a272f514726e5041104/opentelemetry_instrumentation_urllib-0.58b0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "849448171907cb9ced5bdc5be18f8cc8a8234bb2ec695f20c69f1330b336f2fb",
"md5": "7f10d9e6d92de9e0b12a83a64cccbb58",
"sha256": "071e5a28a1c4198cfa33937484f4b0b1068aab26d75e71e55f598a717f268d0a"
},
"downloads": -1,
"filename": "opentelemetry_instrumentation_urllib-0.58b0.tar.gz",
"has_sig": false,
"md5_digest": "7f10d9e6d92de9e0b12a83a64cccbb58",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 13932,
"upload_time": "2025-09-11T11:42:58",
"upload_time_iso_8601": "2025-09-11T11:42:58.798062Z",
"url": "https://files.pythonhosted.org/packages/84/94/48171907cb9ced5bdc5be18f8cc8a8234bb2ec695f20c69f1330b336f2fb/opentelemetry_instrumentation_urllib-0.58b0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-11 11:42:58",
"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"
}