Tracing has a weird integration with Client Middlewares #11437
UltimateLobster
started this conversation in
General
Replies: 1 comment
-
Not sure we thought about it during development. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
After testing abit with the new client middlewares feature I've noticed something weird about the integration of the feature with tracing.
It seems that the tracing hooks for
on_request_start
,on_request_end
andon_request_exception
are called before the client middlewares. It seems weird to me as I would expect tracing hooks to be as close to the actual sent requests as possible.That means that if I have a middleware that modifies the requests, or retries the requests multiple times, it will not be reflected in the traces. Here I've created a minimal retry middleware and trace configs to reflect the issue.
For an endpoint that always returns 500 we will see the following:
Which means if I use OpenTelemetry instrumentation, I would see a single request where I would expect to see 3.
Things become even more complicated when you take the automatic retry for idempotent methods into account.
At that point I can have up to 6 attempts to send the request, but tracing-wise, I would only see one which (at least for me) is completly unexpected.
Is this a bug or the intended behavior? I would love to see some documentation about the way client middlewares should be integrated with other features of aiohttp.
Beta Was this translation helpful? Give feedback.
All reactions