Closed sam-mosleh closed 1 year ago
The AsyncClient
is imported from httpx.AsyncClient
, they are the same thing.
If you can't use
from httpx import AsyncClient
for instruments, even though I can change Authlib's implementation, there will always be other libraries don't use httpx.AsyncClient
directly.
In my opinion, it is the instrument tool's job to take care of these things. It can monkey patch httpx.AsyncClient
directly on class level.
Since Opentelemetry replaces the whole class with the new one, they won't be the same because AsyncClient
will refer to the old, unpatched class.
You are right about other libraries, but since your Authlib is widely used, fixing it here will save a lot of time for larger projects.
@sam-mosleh I'm happy to receive a patch then. Thanks for the feedback.
Is your feature request related to a problem? Please describe.
OpenTelemetry introduced an automatic way to monkey-patch popular libraries to trace them, but Authlib can't take advantage of it. Currently, the only way for instrumenting Authlib's Httpx client is by instrumenting each client instance:
Which for large code bases is a tedious job
Describe the solution you'd like
Being able to instrument clients without changes to the code base which is achieved for
AsyncOAuth2Client
by changing inheritance fromAsyncClient
tohttpx.AsyncClient
Additional context
I would be happy to try to open a PR for this. Thanks!