Generic http client handler does not work well with okhttp #1641
Description
I'm trying to use HttpClientHandler with OkHttp and use it inside network interceptor.
When HttpClientHandler.handleStart is invoked, it supposed to inject header.
Unfortunately, OkHttp uses builder pattern to construct requests and the only way to add a header is through builder (see https://stackoverflow.com/questions/32196424/how-to-add-headers-to-okhttp-request-interceptor)
It is possible to supply HttpClientHandler with request builder, but it seems to be inefficient (re-building and extra allocations).
The only efficient way to instrument okhttp seems to be:
- create request builder
- start span
- inject trace context
- build request
- fill attributes (yes, you can fill them from request, but not the builder)
But this approach also does not work with the network interceptor (and it nice to be able track redirects and retries without thinking about the position in the handler list)
So I think the right long-term plan is to fix it on the okhttp side.
@rghetia am I missing something in the handler design? what http libs it intends to work with?
What version of OpenCensus are you using?
0.19.0