Created
October 20, 2016 21:26
-
-
Save esoxjem/c0797fe65e37adbcdce471a65d0b6814 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SamplingInterceptor implements Interceptor | |
{ | |
@Override | |
public Response intercept(Chain chain) throws IOException | |
{ | |
Request request = chain.request(); | |
DeviceBandwidthSampler.getInstance().startSampling(); | |
Response response = chain.proceed(request); | |
DeviceBandwidthSampler.getInstance().stopSampling(); | |
return response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, just happened upon this and going to offer some unsolicited advice.
This
DeviceBandwidthSampler.stopSampling()
appears to be used for measuring the time to complete an entire call.This code stops sampling after the response headers come back. It looks like it is meant to be called after the response body is exhausted. You may want to check out the new OkHttp EventListener API.