-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Analytics API #270
Comments
It would be great if okhttp would in general get a simple logging facility to see what is actually sent and received over the wire. |
Also logging connection reuse should be helpful. |
I'd like to see overall overhead (bytes/ms) per request/response since w/SPDY, HTTP2 compression could dramatically impact things. |
Strawman:
We'd call the observer before and after we attempt to do I/O. Fields in The application layer could plug into this to do logging or higher-level things. |
|
Connection is the easiest way to get access to the |
@tommyd3mdi our new interceptors API can be used to log exactly what went over the wire. See the newly-authored Interceptors doc for a very specific example. I think that solves about 60% use case of this request. Making me feel justified in punting it to the icebox. |
@swankjesse We've tried using interceptors but they don't allow us to analyze a connection at the granularity we want to. We are looking for more low level details like DNS lookup time, SSL negotiation time etc. Exposing HttpEngine with hooks for collecting this info would be very valuable to us. |
With OkHttp 2.6 you'll be able to provide your own instrumented DNS for that, and you can already provide your own instrumented SSL Engine to time that. So what we really need is just a nice API to put it all together. |
Updated sketch:
|
I was playing around this class to expose some metrics for prometheus, and I noticed that okhttp/okhttp-tests/src/test/java/okhttp3/EventListenerTest.java Lines 881 to 899 in d041837
I'm sure this is gonna be fixed in the next release(s) of okhttp. As a workaround, I think my only option at this is to place the metrics reporting in the In my case I know there won't be multiple connections |
@bric3 sorry about that. Will fix. |
@swankjesse Thanks. I was wondering if I mis-understood how event were sent. I'm sure there's some challenges around that with protocols like websocket or http/2. Thanks again for this work ! |
@swankjesse I would like to monitor request by their route as defined in Retrofit. However this appear to be difficult to capture this information in Retrofit, see square/retrofit#2732. For bootstrapping the idea I talked about using Do you think OkHttp could introduce another concept in that regard ? |
@swankjesse <https://github.com/swankjesse> I would like to monitor
request by their route as defined in Retrofit. However this appear to be
difficult to capture this information in Retrofit, see
square/retrofit#2732 <square/retrofit#2732>.
For bootstrapping the idea I talked about using Request.tag to pass along
this contextual route data, but I don't think this is wise regarding the
tag usage documentation.
how are you planning to do the monitoring? For example, is it a timer? One
thing you could do is add a synthetic request header that your "start"
timer removes. There are probably other ways, too.
|
@adriancole Actually I implemented an eventlistener that feeds prometheus collectors (gauge, summary, counters). Summary are the closest thing to timers if compared to micrometer. (But for reasons outside of this scope I'm using summary instead of histograms). I considered this approach as well in retrofit, but since I cannot modify the request at the right moment / stage in retrofit I cannot capture the path of the retrofit annotation. |
@swankjesse EventListener callEnd does not call everytime after callStart |
@hamberluo For a workaround look at #270 (comment) |
@bric3 same workaround with mine. I wonder any other? |
Is it time to move out of experimental? #4068 |
@yschimke There'is still some bugs in the implementation see the above comments. e..g this one #270 (comment) |
Can you file a separate issue? Would be really helpful. Specifically my question was prompted by whether the API is finalised. I’m sure we will keep finding some bugs. |
I’m still happy with the API. I would like to add events for caching + conditional caching, but that isn’t urgent. |
Final API released! Yay! |
fantastic!
|
Regarding the API, what about the above comments, which in short demands some kind of contextual data in the events themselves. |
@bric3 Can you file separate issues for the other comments, I am suggesting that feedback like this possibly got missed because of the one big thread. |
FYI: we’re adding new events in OkHttp 3.14. |
We should add verbose logging for the response cache. Folks occasionally are puzzled when the cache doesn't work. Let's make it easy for them to figure out why.
It would also be handy for debug panels and optimizers to monitor bytes in and out, connections created, etc.
The text was updated successfully, but these errors were encountered: