Application Performance Management(APM)

Cenk Türker
Huawei Developers
Published in
11 min readNov 5, 2020
APM

What is the APM ?

Application Performance Management (APM) generally provides important services for web and cloud services, with features such as monitoring and managing software in terms of accessibility and performance, detecting problems that cause interruptions in accessing especially critical applications.

APM features and Key Functions

Key Functions of APM

APM has some features that its user’s can handle facing problems easily, such as;

  • A collecting key app performance data automatically
  • Discovery modelling and display
  • Deep-dive monitoring in an application context
  • Analytics of data
  • •Discovery modelling and display User-defined transaction profiling

Working Principle of APM

App Performance Management (APM) of HUAWEI AppGallery Connect provides minute-level app performance monitoring capabilities. You can view and analyze app performance data collected by APM in AppGallery Connect to comprehensively understand online performance of apps in real time, helping you quickly and accurately rectify app performance problems and continuously improve users experience.

Schema of APM working principle

How to Use APM in HMS ?

APM in HMS

Integrating the AppGallery Connect SDK

Before integrating the APM SDK, be sure of your app has been integrated with AppGallery Connect SDK and AppGallery Connect plug-in. For details, please check that Getting Started with Android page.

Integrating the APM SDK

1- In the development environment , we need build.gradle file which is APM SDK dependency to the app-level.

2- Please add the following items to app-level obfuscation configurations:

3- If you are using AndResGuard, add the following to its trust-list to prevent obfuscation:

4- If your app uses the AndroidX class library, you should add the following configuration to gradle.properties, by this way, the APM will be adapting to AndroidX automatically.

Integrating the APM Plug-in

1- Build.gradle file needs to get added to APM plug-in to the app-level.

2- Add the APM plug-in to the project-level build.gradle file.

After completing the integration process, with the below table step your application will be compiled again.

Build project

After whole steps completed, Integration operation is ended for APM. As the next step, we are going to analyze our data on performance monitoring screen .Lastly we can complete with APM performance data by displaying results.

How to Enable App performance management

Now , you are going to know , how to enable app performance management step by step.

1- Firstly, after sign-in with your Huawei Developer account, go by slipping App Services →Huawei AppGallery → My apps.

2- On that screen choose your own app ,then on bottom left side you will see Quality →APM as the below

3- Last but not least, it should be activated by clicking on “Enable” button as shown below table.

Enable button for APM on AppGallery Connect

Note: While enabling APM, you need to settle the storage location. After that configuration in agconnect-services.json is automatically updated according to this.
If you have set the data storage location while enabling APM, you need to download agconnect-services.json again and integrate it into your project after the service is activated.

In the below table, you can check if the application performance data is properly displayed, but there may be a delay of 15 minutes.
You may not be able to view data simultaneously, so constantly refresh your page.

APM Overview

If the page display the data incorrectly or page appears as empty for a long time, please check Viewing Debug Logsout page.

Viewing and Analyzing App Performance Data

App launch duration

In this section , you are going to find out duration between the time when the app is launched in the background and that when the first page is displayed.

App Launch Duration

This function monitors the app launch duration, so that you can understand the app launch performance in a timely manner. It uses the app launch duration as an indicator and calculates the percentile value of the app launch duration to display the overall distribution of the app launch duration.

In the below table, by clicking App analysis →App launch duration →View Details” you can reach more information about it or you can view the same schema by following Overview →Launch Duration(Indicator Overview) →Details steps.

App Launch Duration 2

Consequently, While following Overview →Launch duration screen you are going to investigate about;

  • Between which hours Application is started averagely,
  • % of launch speed in application usage,
  • According to the application version analyzes are available by starting time,
  • Average start time

In the below table, by clicking App analysis →App launch duration →View Details” shows the slow frame rates in different dimensions (such as the version number, country/region, device model, level-1 region, system version, carrier, and network). The dimensions can be sorted by slow frame rate, number of samples, or number of sessions. When statistics are collected by version, the chart displays the slow frame rates of all versions.

Moreover, while clicking “View Sessions” on the right side you are going to come upon below table.

Session List 1

You can reach information such as Application starting time , how much time that needed , which smartphone model is used during this time, connection from which country ,Network are used.

In addition, There is animated cursor on graph so you can navigate on the graphs and examine numerical data about all units.

Lastly, if you click “View Details” under “Operation” column you will see “Session List” page in the below table. In this section also, you can get that knowledge;

  • CPU usage duration,
  • Memory usage,
  • Information about device
  • Network data
Session List 2

Background and Foreground Activity Performance Data

Background activity duration: duration from the time when the last activity calls the onStop() method before an app is switched to the background to the time when the first activity calls the onResume() method after the app is switched to the foreground.

Foreground activity duration: duration from the time when the first activity calls the onResume() method after an app is launched or switched to the foreground to the time when the last activity calls the onStop() method before the app is switched to the background.

You can reach below table following Overview →App Analysis → App foreground or background activity

Background Activity
Foreground Activity

1- In top left ,shows the foreground activity duration distribution. When you move the cursor, the specified frontend activity duration and its percentile are displayed.

2- In top right, shows the foreground activity duration distribution by time. When you move the cursor, the median frontend activity duration and durations of 5th and 95th percentiles at the specified time points are displayed.

3- In bottom left, shows the foreground activity duration distribution by version. When you point to a bar of a version, the median frontend activity duration and durations of 5th and 95th percentiles, number of samples, and number of sessions are displayed.

Network Analysis

Performance data includes the duration between the time when an app sends a network request to your server and the time when the response from your server is complete, request status code, request load, and response load.

Network Request Indicator Definition

  • URL: network request URL .
  • Number of requests: the number of times a request URL is invoked.
  • Request duration: interval between the time when an app sends a request and the time when the app receives a response from the server.
  • Success rate: percentage of requests whose status code is 2xx or 3xx to the total number of requests.
  • Request load size: number of bytes of the network payload for upload in an app.
  • Response load size: number of bytes of the network payload to be downloaded in an app.

You can get below page following Overview Network Analysis steps.

Network Analysis

In the above table , APM monitors HTTP/HTTPS network requests initiated by the OkHttp, URLConnection, and ApacheHttpClient and clusters data of the same type of network requests by matching URL clustering rules, helping you understand the network request performance trend and detect network problems in a timely manner.

Please click on “View details” under “operation” column for displaying network request. The details page contains the Request duration and Request success rate tab pages.

Request duration

Request Duration

1- In top left, figure shows the distribution of network request durations. When you move the cursor, the percentile of the specified network request duration is displayed. For example, the median network request duration is 1.6 s, indicating that 50% of network request durations are less than or equal to 1.6s.

2- In top right, figure shows the network request duration distribution by version. When you point to a bar of a version, the median network request duration and durations of 5th and 95th percentiles, number of samples, and number of sessions are displayed.

3- In bottom left, figure shows the network request duration distribution by version. When you point to a bar of a version, the median network request duration and durations of 5th and 95th percentiles, number of samples, and number of sessions are displayed.

Request Success Rate

The following schema describes Request success rate page that;

1- In top left, Average network request success rate, that is, 100%.

2- In top right, the rate of top 10 status codes of network requests, the rate of response code 200 is 100%.

3- In bottom left, the network request success rate distribution by time. the network request success rate at 08:00 on October 5 is 100%.

4- In bottom right, the network request success rate distribution by version. When you point to a bar of a version, the network request success rate of the corresponding version is displayed. In the figure, the network request success rate of version 1.0 data is 100%.

Request Success Rate

Viewing ANR Data

ANR is a mechanism that ,UI thread of an Android app is blocked for too long , “Application Not Responding” (ANR) error is triggered. In this situation APM service records basic key information when an ANR occurs.

If the app is in the foreground, the system displays a dialog to the user just like pop-up menu and gives the user opportunity to force quit the app.

App ANR Indicators

  • Occurrences:ANR problem occurence time within a specified time range.
  • Affected users: number of users affected by ANR problems within a specified time range.
  • ANR-affected user rate: total number of app users within a specified time range and rate of users.
  • ANR-affected user rate trend: rate of ANR occurrences to app launch times within a specified time range, that is, the probability that an ANR problem occurs during a single app launch.
ANR Analysis

In above general ANR analysis screen, In here you can find all data information about ANR such as;

  • Occurrences,
  • Affected users,
  • ANR-affected user rate,
  • ANR affected user rate trend
Top 5 problems

Top left on the page, especially you will see data “Top 5 problems in last 24 hours” with the red zone area.

ANR-affected user rate trend

In ANR-affected user rate trend if you wish you can examine in detail by filtering tab on the right ,according to ;

  • By time,
  • By app version,
  • By OS version,
  • By device model

In lowest part on page , at “Problems (by affected user rate)” you can some data about affected users by ;

  • Affected users in last 24 hours,
  • Affected user rate in last 24 hours,
  • Occurences,
  • Affected users,
  • First occured & last occured time
Problems (by affected user rate)

When you click on “View details” under “Operation” tab. You will find the opportunity to analyze graphically in more detail.

ANR analysis list

In the bottom of the page you will see the “records” section. In this part you can find various information such as;

  • ID,
  • First occured,
  • App version,
  • OS version,
  • Device Model,
  • Operation
Records

In “Operation” tab , while clicking on “View details” this time you will come across enormous data page and you will find out in detail;

  • Device information,
  • System information,
  • App information
Information

Except those ,This page displays ;

  • Main thread steak info,
  • Other thread steak info,
  • System logs,
  • ANR info

when an ANR problem occurs, helping you comprehensively understand various information when an ANR problem occurs in your app.

In addition, APM provides the record export function. You can click on “Export” to export all information on the page for comparison and analysis.

Log Info

You can find out how to disable APM in your application with that link.

Here is the some FAQ’s which I create my own while investigating on APM.

FAQ’s

Q: Does the APM provide to show the user’s smartphone information (such as system version, Model, Memory, Carrier, OS version, CPU model etc) ?
A: Yes it does, the APM makes it possible.

Q: Does the APM supported about CPU usage duration ,how much CPU is used by system and user ?
A: Yes the APM provides information about CPU usage duration ,both system and user.

Q: Can the user see, how much memory is used during APM is actively working ?
A: Yes the user can instantly view the memory usage.

Q: Can users get information about how long the application they run on their device runs in the foreground and background by using APM?
A: Of course, Background-Foreground activity duration time is shown to user as start time period and total duration time.

Q: What frameworks does APM SDK support and give benefit for network request monitoring?
A: Via the linked URLConnection and OkHttp frameworks is shared start-end time, required time for connection, Status code, Request load, response load, download speed with the user in detail.

Q: Does the APM SDK only supports Android applications ?
A: The APM SDK support for multiple platforms such as HTML5 Page Analysis, the iOS platform, the web system, Network hijacking analysis as well as Android platform.

Q: What if network data is not responding, how can I check out that where the main defect ?
A: In the ANR analysis section presented by APM for the solution of the main problem, the number of users affected by this situation, their rate and detailed information in graphical terms are provided to us. The application automatically triggers ANR and in case it fails to get an answer, it ensures the detection of the problem with stored system log files and ANR info.

I hope this is a useful article for you, see you in my next post, goodbye…

References

https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-apms-introduction

--

--