-
Notifications
You must be signed in to change notification settings - Fork 626
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
httpx: add the is_instrumented
flag to the transport
#3106
base: main
Are you sure you want to change the base?
httpx: add the is_instrumented
flag to the transport
#3106
Conversation
if getattr(client, "_is_instrumented_by_opentelemetry", False): | ||
if getattr( | ||
client._transport, "_is_instrumented_by_opentelemetry", False | ||
): | ||
_logger.warning( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't log a warning if someone instruments a new client with the same transport. So I think we need to keep the attribute and warning on the client, but silently do nothing if the transport is already instrumented.
85dbb70
to
7660a00
Compare
I think the title and description do not match the code, you are moving the flag that signals that the transport has already been instrumented to the transport itself. |
Right. The PR started as what the title suggests, and I modified the code given this comment: #3106 (comment) |
is_instrumented
flag to the transport
@xrmx Should be better now. 🙏 |
@xrmx this is not ready, sorry. I'm missing something, now I have 2 spans on my test, instead of 3 (before my changes were 3). I still need to fix it somewhere. |
We've found a bug where if the
transport
is reused in different HTTP clients, the transport gets instrumented multiple times.Run the following MRE:
You'll see 2 spans.
This PR proposes adding the
_is_instrumented_by_opentelemetry
to theTransport
as well.