Building a Telemetry for Android/iOS Realtime App

Today we will discuss about how to build a telemetry system while building an app. In this we will be taking of how we do it in Coral Server which we have built for real time apps.

Why telemetry is important?

Telemetry is important to capture the events happening on the device with-in your app. These events can then be joined with other data to draw useful conclustions.

An example for one of our clients: Restaurants get order notification on tablet which results into a ringing bell. Once they press the accept button, they have to open the order and confirm it or cancel. Now for our system its very hard to know that whether the bell rang and then he saw the order details. In the above case the telemetry helps us to stich the events together.

How to build a simple Telemetry System?

Lets first look into device side code and we will be taking android as an example. We will be putting java code here. We use a blockingQueue to capture Events from the app in ordered manner. Since we don’t want to publish events as they happen. We can push them to the server async.

You can add an event to the event manager by just calling the addEvent api. In the above code we can capture upto 500 events without blocking.

Below is rough diagram of the different classes and there flow.

Each activity where you want to publish events you simple call Telemetry Manager api with event information.

You write a background thread which in the above diagram we are calling as TelemetryUploadWorker to push the events to server. In the below code we are publishing 10 events at a time.

What happens on server side?

Since the Coral Server uses websocket we stream these events to the server.

On Server we further batch this events into bigger objects and dump periodically in Google cloud storage.

For the most of brief duration we buffer the batches in memory and once they reach a size of roughly 1MB we flush them to cloud storage.

Let us know if you have questions on this way of capturing Telemetry from an Android app.

A simple Telemetry client code can be found in the repository

Reach out to us if you are interested in using Coral Server for your real time apps.

Simplifying writing cloud connected Apps.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store