Application Performance Tracking in HMS (APM Service)

Sezer BOZKIR
Huawei Developers
Published in
4 min readMay 27, 2020
Huawei APM Service
Huawei APM Service

Hi everyone,

One of the important issues in the world of application development is the acceptable system resource consumption and performance of our application on devices. Where you need a tool for these and similar systemic concerns, I come across APM service. Here, I recommend APM service to the help of developers suffering from this issue…

APM service, provide this kind of features your application:

  • Application Screen Creation Performance Data
  • Application Launch Performance Data
  • Performance Data on Network Operations
  • Configuring Clustering Rules

recognizes the possibilities of seeing and evaluating. Before I start to examine these features, I guess it would be a better start to learn how to integrate the APM service into our application.

Integration

WARNING: Before integrating the APM SDK, be sure to integrate your app’s AppGallery Connect SDK and AppGallery Connect plug-ins. For details, please see the first integration section of the application.

https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-get-started#addjson

By opening the “build.gradle” file of our application at the application level in Android Studio,

// ... 
apply plugin: 'com.huawei.agconnect.apms'
dependencies {
// ...
// Add APM SDK library dependency
implementation 'com.huawei.agconnect:agconnect-apms:1.2.1.300'
}

After adding the dependency, you will be able to view application launch performance data and application screen rendering performance data. It is necessary to implement the APM extension which is extra for the other 2 screens.

For this 2 screens, we add the following codes to the build.gradle file at the project level in Android Studio:

buildscript {
repositories {
// Add the maven repository
maven { url 'http://developer.huawei.com/repo/' }
}
dependencies {
// ...
// To benefit from the latest APM feaures, update your Android Gradle Plugin dependency to at least v3.2.0
classpath 'com.android.tools.build:gradle:3.2.0'
// Add the dependency for the APM plugin
classpath 'com.huawei.agconnect:agconnect-apms-plugin:1.2.1.300'
}
}

Note that your application must have received the following permissions from the user in order to activate the APM service:

android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE

After the changes to the application, we can proceed to the configuration settings section of your application through the App Gallery Console:

  1. Recompile your app
  2. Install and launch your app on your device
  3. Connect to AppGallery Connect and choose your app
  4. Select your project and activate the APM service in Quality> APM.

There is a situation I would like to mention here. If you have created your application from scratch like I do right now, you will be asked for location information, in case you make this adjustment, you have to re-download the “agconnect-services.json” file and again that you put in your application and update the version in your application. (see here for details)

If everything is ok, you can see the data of your application in the interface within 15 minutes. When you integrate your application for the first time, you can look at the image you will encounter and the state that contains the values after integration from here:

First Version
After the data started coming …

Use of Features

After completing the integration steps above, the APM service will automatically track the actions of your application, so all you have to do is connect to your application via the App Gallery Console and start reviewing the results.

Reviewing APM Debug Data

If you think something is wrong with APM, you can look at the APM logs in debug mode. After adding the following code between the “<meta-data>” tag in your AndroudManifest.xml file, you can read the logs with the command “adb logcat -s com.huawei.agc.apms”.

<application>
<!-- Set this flag to 'true', debug logs of APM will be printed in logcat, default value is 'false'-->
<meta-data
android:name="apms_debug_log_enabled"
android:value="false" />
</application>

Graphical Features

Application Launch Time Chart
Choosing Values
Version based distribution
Indicators on the Home Page
Network Analysis Chart

Of course, these are the interfaces I see, you can reach more detailed services through the document and you can start using it for your application.

You can ask your questions about the APM service at the Huawei Developer Forum or under this topic. If you want to browse similar articles, you can browse the Huawei Mobile Services medium channel.

Hope to see you in another article … 🙂

--

--