Event hooks system doesn't allow hooking an requests that don't have a response #2067
-
|
I'm using the hooks system to do distributed tracing. That means I need to end my span when the request completes, either with an error or not. It seems that when a particular request encounters a read timeout, the response hooks won't be called. The hooks system is nice because it allows capturing all requests including redirects or auth flows. But it seems like I might need to actually subclass the client to ensure potential errors are reported, which means I'll have to worry about the implementation details a bit more than is desirable. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
For more fine grained detail you could look at the import httpx
def log(event_name, info):
print(event_name, info)
client = httpx.Client()
resp = client.get("https://www.example.org/", extensions={"trace": log})That's probably not really quite what you're looking for, but perhaps it'd be helpful? I suppose the alternative might be adding an It'd also be interesting to take a look at what third party tracing packages exist for |
Beta Was this translation helpful? Give feedback.
Hi @allenhumphreys
For more fine grained detail you could look at the
traceextension... https://www.encode.io/httpcore/extensions/#traceThat's probably not really quite what you're looking for, but perhaps it'd be helpful?
I suppose the alternative might be adding an
'exception'event hook or something like that?It'd also be interesting to take a look at what third party tracing packages exist for
requests?