mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-28 20:52:57 +08:00
Add documentation for request/response hooks for requests instrumentor (#2704)
This commit is contained in:
@ -31,6 +31,30 @@ Usage
|
|||||||
Configuration
|
Configuration
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
Request/Response hooks
|
||||||
|
**********************
|
||||||
|
|
||||||
|
The requests 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
|
||||||
|
|
||||||
|
# `request_obj` is an instance of requests.PreparedRequest
|
||||||
|
def request_hook(span, request_obj):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# `request_obj` is an instance of requests.PreparedRequest
|
||||||
|
# `response` is an instance of requests.Response
|
||||||
|
def response_hook(span, request_obj, response)
|
||||||
|
pass
|
||||||
|
|
||||||
|
RequestsInstrumentor().instrument(
|
||||||
|
request_hook=request_hook, response_hook=response_hook)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
Exclude lists
|
Exclude lists
|
||||||
*************
|
*************
|
||||||
To exclude certain URLs from being tracked, set the environment variable ``OTEL_PYTHON_REQUESTS_EXCLUDED_URLS``
|
To exclude certain URLs from being tracked, set the environment variable ``OTEL_PYTHON_REQUESTS_EXCLUDED_URLS``
|
||||||
|
Reference in New Issue
Block a user