opencensus-python
opencensus-python copied to clipboard
Enhance httpx tracing
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.
@macieyng update the changelog
Thanks @lzchen for running the pipeline. I will fix it tomorrow.
@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?
@lzchen can you run the pipeline? Thanks! 🙏
@aabmass @jeremydvoss @hectorhdzg @calleo 🙏
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?