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

Enhance httpx tracing #1186

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

macieyng
Copy link

@macieyng macieyng commented Jan 24, 2023

In httpx Advanced Usage docs there is a chapter Request Instances where they show alternative way of sending requests, where you can use once initialized client to send various of different requests to the same host.

Current implementation of tracing doesn't cover that use case, because calling structure is different while function Client.send is actually what is common and it returns Response object.

In a nutshell:

class Client:
    ...
    def request(...) -> Response:
        ...
        request = self.build_request(...)
        return self.send(request)

so when I have something like this:

req_1 = httpx.Request(...)
req_2 = httpx.Request(...)

with httpx.Client() as client:
    client.send(req_1)
    client.send(req_2)

It's not traced.

The solution in this PR will cover both use cases - the standard one (requests-like) and the advanced usage.

@miqm
Copy link

miqm commented Jan 26, 2023

@macieyng update the changelog

@macieyng
Copy link
Author

macieyng commented Feb 2, 2023

Thanks @lzchen for running the pipeline. I will fix it tomorrow.

@macieyng
Copy link
Author

macieyng commented Feb 3, 2023

@lzchen ready for running the pipeline 🚀
My bad for not running tox locally before pushing. It turns out that implementation has to be a little bit different from requests.
@inirudebwoy can you review this too, please?

@macieyng
Copy link
Author

macieyng commented Feb 6, 2023

@lzchen can you run the pipeline? Thanks! 🙏

@macieyng
Copy link
Author

macieyng commented Feb 7, 2023

@macieyng
Copy link
Author

macieyng commented Feb 8, 2023

Failed to import opencensus.ext.zipkin.trace_exporter.
Possible hints:
* AttributeError: module 'opencensus' has no attribute 'ext'
* ModuleNotFoundError: No module named 'opencensus.ext'
Failed to import opencensus.ext.stackdriver.trace_exporter.
Possible hints:
* AttributeError: module 'opencensus' has no attribute 'ext'
* ModuleNotFoundError: No module named 'opencensus.ext'

That's not something that I touched and on my machine it fails even earlier, but that's because I'm running it locally on mac. @lzchen can I get your support with sorting this out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants