opentelemetry-python-contrib
opentelemetry-python-contrib copied to clipboard
HTTPX instrumentation - document how to log request payload and response on response_hook
trafficstars
Is your feature request related to a problem? After reading the httpx instrumentation docs it is clear I need a response_hook and how to use it. But it has no example how to really use this with the span, request, response attributes to log the payload from request and response.
After digging into __init__() I see both ResponseInfo and RequestInfo have a stream property that could potentially be the solution, but each of them are a different type:
class RequestInfo(typing.NamedTuple):
....
typing.Optional[
typing.Union[httpx.SyncByteStream, httpx.AsyncByteStream]
]
class ResponseInfo(typing.NamedTuple):
...
stream: typing.Iterable[bytes]
In those cases it is not very clear an easy way to log the information from the payload.
Describe the solution you'd like A simple example of response_hook in the docs with logging of payload of request and response.