-
Notifications
You must be signed in to change notification settings - Fork 714
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
OkHttp tracing breaks when backlogged #292
Comments
Our solution to this was to create our own Call.Factory which actually creates a new OkHttpClient for each call creation. The new client adds an interceptor that does the context propagation: https://gist.github.com/brianm/5358a1aa3e39b0ffe3467e19e4ec740c This might not be super palatable for something that tries to be transparent, but even the |
I think the short term way out of this is to make brave's current tracer apis accept an explicit parent (as opposed to requiring usage of thread locals). Future apis can sort the context propagation thing more elegantly. |
Brave 4.3's okhttp approach is a call factory which isn't subject to this problem |
We attach state read by interceptors by controlling the OkHttp's Dispatcher's ExecutorService.
It works like this..
This works for synchronous requests (since they don't use the dispatcher thread anyway) and normal asynchronous requests.
It doesn't work when there are more in-flight connections than permitted, because asynchronous requests are pushed into a ready queue before they are executed. The ready queue is not processed by the calling thread of the request, so the re-attach won't work. When an interceptor runs on a delayed request, it cannot see its calling span which breaks tracing.
I was thinking that maybe the application interceptor might not have this problem. If the host/connection limit was enforced (via the mentioned queue) at the network level, I would be able to coordinate the state by dual-registering an interceptor. This interceptor could re-attach the state without relying on thread locals by mapping application/network level requests.
Sadly, this doesn't work because the host/connection limit is enforced (via the mentioned queue) at the application level, so I'm stumped.
I would like to be able to trace requests especially when they are backlogged. Any ideas?
Hats off to @brianm for finding this problem, btw
here's a copy of this in stackoverflow as I'm not sure if this needs a change to okhttp or not https://stackoverflow.com/questions/41040727/propagating-state-even-when-backlogged
The text was updated successfully, but these errors were encountered: