Firebase Performance Monitoring for Android

Your user is on a wide variety of devices, in a wide variety of networks, in a wide variety of locations all over the world. If you want to optimize the performance of your app, metrics that tell you exactly what’s happening during the critical moments of your app’s use. You need that information to come directly from users.

Now, You can get using Firebase Performance Monitoring. By integrating the SDK into your app, and without writing any code, your performance dashboard in the Firebase console will collect information about your app’s performance, as seen by your users. You’ll get data about your app’s startup time and details about its HTTP transactions. Using the provided API, you can instrument your app to measure those critical moments that you want to understand and improve. Then, in the dashboard, you can break down the data by Country, Version, Device, OS, Radio, Carrier, MIME type.

Install Firebase SDK in APP


This guide shows you how to use Firebase Performance Monitoring with your app.

1 Prerequisites

You need a few things set up in your environment:

  • A device running Android 4.0 +, and Google Play services 11.0.4 +
  • The Google Play services SDK from the Google Repository, available in the Android SDK Manager
  • The latest version of Android Studio 2.2+

2 Add Firebase to your Android project


Add Firebase to your app from Android Studio using the Firebase Assistant.To open the Firebase Assistant in Android Studio:

  1. Click Tools > Firebase to open the Assistant window.
  2. Click to expand one of the listed features (for example, Analytics), then click the provided tutorial link (for example, Log an Analytics event).
  3. Click the Connect to Firebase button to connect to Firebase and add the necessary code to your app.

Firebase Performance Monitor

3 Add Performance Monitoring to your app


  • Add the following dependencies project-level build.gradle : check the latest version

Add the following dependencies app-level build.gradle :

  1. Below apply plugin: 'com.android.application', add the following line:
  2. Add the following to the dependencies section:
  3. If your app uses other Firebase SDKs, you should also change the version to 11.0.4 for those SDKs.

 

Recompile your app. Automatic traces and HTTP/S network requests are now monitored.

If you just install the SDK, you still get a few out-of-the-box traces, the most important one being app start. This is the time between the app code start loading until the app is responsive to the user. Firebase also has a trace that monitors the foreground and background as well.

App code performance.

What kind of delays your user see as they interact with the app, or how much frame drops they see in the animation to monitor that Firebase built feature called Traces.

The other category of issues is about network activity between your app and the backends that it uses for that Firebase monitor network requests.

Traces


The easiest way to define a trace is its performance report between two points in your app.

All you need to do is create a trace name or a trace object, give it a name, start it and stop it. That name you give it becomes your context.

Add the @AddTrace annotation to trace specific methods

You can add the @AddTrace annotation to methods in your app and provide a string to identify the resulting trace. This causes a trace to start at the beginning of this method, and to stop when the method completes. Traces created in this way do not have counters available.

Trace Metrics

In terms of metrics, by default you get the trace duration, so how much time took place between the start from the stop. You can attach custom metrics using counter API. Which you see an example of here.

Anyone of these events you can just give it a name, You can count it increment it and we’ll tally up those events and report them as custom metrics attached to your trace.

Network Monitor


An HTTP/S network request is a report that captures the time between when your app issues a request to a service endpoint and when the response from that endpoint is complete.

  • Response time: Time between when the request is made and when the response is fully received
  • Payload size: Byte size of the network payload downloaded and uploaded by the app
  • Success rate: Percentage of successful responses compared to total responses (to measure network or server failures)

 

Related Post

Firebase Crashlytics

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *