-
Notifications
You must be signed in to change notification settings - Fork 0
Ping class
Ping was created with the intention of helping developers profile, optimize and benchmark their API calls. API calls are one of the biggest factors contributing to app efficiency and with Ping, you can track the start and end of any API call.
There’s a functionality for streamed API calls that lets you record the network activity. With the help of method Ping.tick(), you can communicate to the Traceratops dashboard each time you receive some data from the connection. Additionally, if you wish to track how much data is received, you can use the method Ping.tick(int sizeInBytes).
Following is an example showing Ping usage -
private String getResponse(String myUrl) {
Ping.PingSession mySession;
String message = “Ping for URL: “ + myUrl;
url = new URL(myUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setReadTimeout(15*1000);
connection.connect();
mySession = Ping.startSession(message);
reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
stringBuilder = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
stringBuilder.append(line + "\n");
Ping.tick(mySession, line.length());
}
Ping.endSession(mySession);
}In the current version of Traceratops app, you can see all the Pings (and ticks) in ‘Logs’ tab along with all other logs and crashes. In order to make it easier to monitor Pings, we plan on adding a separate screen where all the Pings corresponding to a single session (i.e. single API call) will be clubbed together.
Got more questions or suggestions?
Email us at bubblegumdevs@gmail.com or create a new issue on our Issue tracker