Ensure httpx.get etc. get instrumented #2011
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This closes #1742 — "httpx instrumentation doesn't work for httpx.get, httpx.post, etc.".
The
httpx.get
,httpx.post
, etc. methods ultimately usehttpx._api.request
, which makes instantiateshttpx._api.Client
. Buthttpx.Client
is modified during instrumentation without updating the value imported in thehttpx._api
module.Fixing this was as easy as also patching the
Client
value inhttpx._api
.Fixes #1742
Type of change
I am not sure if it counts as a feature or bug fix. I'm sure it could be argued both ways, but I decided to call it a bug fix.
How Has This Been Tested?
I made this change and confirmed that it caused spans from the HTTPX instrumentation to be nested properly in my observability backend. I can add tests with a bit of guidance about where to look/modify/what would be desired. But I'd like to get confirmation that this is likely to be accepted before putting in the effort.
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.
I don't think a documentation change is necessary; I'll update changelogs after adding unit tests once confirmed this is desirable.