Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Yelp Varanus Helps Android Apps Monitor and Limit Network Traffic

Yelp Varanus Helps Android Apps Monitor and Limit Network Traffic

This item in japanese

Recently open-sourced by Yelp, Varanus is an Android library aiming to prevent apps from inadvertently consuming too much data. Besides monitoring network traffic, Varanus can also shut off network access if required.

The original goal of Varanus was to protect against bugs where an excessive amount of network traffic is sent, potentially accidentally DDOS-ing the site (as described in this droidcon talk). However, it's suitable for managing and monitoring network traffic more generally.

According to Yelp engineers Sanae Rosen and Kurt Bonatz, Varanus was built with three goals in mind: being simple and hard to break; working as expected out-of-the-box with no configuration; and not requiring much effort to be integrated into different apps.

Varanus enables monitoring or shutting off network traffic both globally and for specific endpoints. It works by intercepting all network traffic in an OkHttp interceptor. As you can see in the following image, the interceptor communicates with a Network Monitor and a Network Shutoff Manager, which are the two main entities in Varanus. Both of them use a user-provided logging service (Traffic Log Persister and Network Shutoff Persister) to store logs wherever the user wants. Logs are only generated when there is actually network usage in order to reduce performance overhead and battery consumption.

Whenever the remote service deems the app is consuming too much data, it can send non-standard 555 or 556 error codes to shut off either data transitting to a specific endpoint or all network usage globally. Being able to send these custom error codes is the only requirement that must be fulfilled server-side to use Varanus in an app.

Varanus is written in Kotlin can be installed using gradle:

// Top level build.gradle
allprojects {
    repositories {

// Module level build.gradle
dependencies {
    implementation "<version-number>"

On a related note, Yelp has also open-sourced its own migration tool Rusty Jetpack.

The tool migrates all files in a git repository to use the new Android X package namespaces. This includes imports, fully qualified references, pro-guard declarations, and warnings about gradle packages that need to be changed.

Rusty Jetpack could be useful for migrating projects where the official migrator provided in Android Studio will not work, as was the case with Yelp projects, say Rosen and Bonatz.

Rate this Article