Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subclassing httpx causing isinstance checks failed #2609

Closed
CNSeniorious000 opened this issue Jun 14, 2024 · 1 comment · Fixed by #2909
Closed

Subclassing httpx causing isinstance checks failed #2609

CNSeniorious000 opened this issue Jun 14, 2024 · 1 comment · Fixed by #2909
Labels
bug Something isn't working

Comments

@CNSeniorious000
Copy link

CNSeniorious000 commented Jun 14, 2024

Describe your environment

OS: Windows-10-10.0.22631-SP0
Python version: Python 3.12.3
Package version: opentelemetry-instrumentation-httpx="0.46b0"

What happened?

I instrumented httpx after some httpx clients being initialized, and then isinstance(client, Client) failed.

I admit that instrumenting code should ideally be placed before any other code, but I hope that even if it is not done this way, it will result in no errors if possible.

Related to pydantic/logfire#264

Steps to Reproduce

from httpx import Client
client = Client()
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
HTTPXClientInstrumentor().instrument()
from httpx import Client
isinstance(client, Client)

Expected Result

True

Actual Result

False

Additional context

Maybe we can use an non-subclassing approach, like patching methods on the original class.

Would you like to implement a fix?

Being open to

@xrmx
Copy link
Contributor

xrmx commented Oct 22, 2024

@CNSeniorious000 Does #2909 work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants