Introduction: For information system services, we usually focus on monitoring core back-end services and use some mainstream Application Performance Management (APM) frameworks for monitoring, alarm, and analysis. So how to monitor and analyze the running state of mobile APP and small program in real time? After the official recommendation of CSDN this time, the APM service provided by Umeng + can achieve our goal. Now we will try to integrate and experience this APM service provided by Umeng +.

background

For information system services, we generally focus on monitoring core back-end services, and usually use some mainstream APM(Application Performance Management) framework for monitoring, alarm and analysis. So how to monitor and analyze the running state of mobile APP and small program in real time? After the official recommendation of CSDN this time, the APM service provided by Umeng + can achieve our goal. Now we will try to integrate and experience this APM service provided by Umeng +.

Because our APP is developed based on Huawei’s Hongmeng operating system, and after registering with UmENG, we found that currently umeng provides the integration and access of Android and iOS mobile operating systems for mobile apps. Huawei Hongmeng OPERATING system is not supported yet. (However, the reported exceptions can be filtered according to hongmeng devices only: The device where the error or exception occurred is HarmonyOS, which does not support HarmonyOS system-level errors.)

Experience processes

For the purpose of experiencing the APM service provided by Umeng +, here is an Android-based Hello World example:

  • First, complete the integration of mobile APP and UMENG SDK according to official documents;
  • Then throw some exceptions in the example (OOM, etc.);
  • Finally, you can see the abnormal information reported by our application on the mobile application monitoring home page of Umeng.

Create Android projects using IDEA

Of course, you need to build a minimalist Android Hello World app before you integrate.

Since I have no experience in mobile terminal development of Android before, and certainly no corresponding development environment, I will directly create an Android application using IDEA here.

Install the AndroidSDK

To create an Android project in IDEA, install the Android SDK first. I use the default location to install it directly here.

Create an empty Activity

Create a virtual appliance

The virtual device is installed successfully

Integrate umENG +APM SDK

Umeng + APM SDK integration process is also quite smooth, refer to the official document recommended by Maven online access to SDK, only three steps: 1. Create an application; 2. Add SDK dependencies; 3. Initialization information is reported.

1. Create an application

2. Add SDK dependencies

3. Initialization information is reported

The configuration and code involved are as follows:

dependencies {

implementation fileTree(dir: ‘libs’, include: [‘*.jar’])

Implementation ‘androidx. Appcompat: appcompat: 1.0.2’

Implementation ‘androidx. Constraintlayout: constraintlayout: 1.1.3’

TestImplementation ‘junit: junit: 4.12’

AndroidTestImplementation ‘androidx. Test: runner: 1.1.1’

AndroidTestImplementation ‘androidx. Test. Espresso: espresso – core: 3.1.1’

// UmENG Base component library (all UMeng business SDKS rely on the base component library)

Implementation “com. Umeng. Umsdk: common: 9.4.2” / / version number (will be))

Implementation “com. Umeng. Umsdk: asms: 1.4.1” / / asms package dependence (choice)

Implementation “com. Umeng. Umsdk: apm: 1.4.2” / / U – apm products package (choice)

}

// umeng

buildscript {

repositories {

google()

jcenter()

maven { url ‘repo1.maven.org/maven2/’ }

}

dependencies {

The classpath ‘com. Android. Tools. Build: gradle: 3.4.0’

// NOTE: Do not place your application dependencies here; they belong

// in the individual module build.gradle files

}

}

allprojects {

repositories {

google()

jcenter()

maven { url ‘repo1.maven.org/maven2/’ }

}

}

// General initialization

public class MainActivity extends AppCompatActivity {

@Override

protected void onCreate(Bundle savedInstanceState) {

// umeng

UMConfigure.setLogEnabled(true);

UMConfigure.init(this, “613b2a85314602341a0df802”, “csdn”, UMConfigure.DEVICE_TYPE_PHONE, “”);

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

}

}

The final configuration

Error after startup: Unable to connect to network

After the project is started, the SDK of Umeng + will report information, which requires networking. However, there is no networking permission after the project is created by default, so an error message will appear.

Configure networking permissions for the APP

Integration success effect

Simulate various anomalies

In order to experience the basic monitoring function of UmENG +APM service, we simulate some exceptions here and see whether these abnormal information can be reported to the APM platform.

  • Ordinary runtime exception: ArithmeticException/NullPointerException
  • StackOverflowError: StackOverflowError
  • Memory overflow exception:.outofMemoryError

Division by 0 exception: ArithmeticException

// Send the exception button click event: simulate the division by zero exception

public void exception(View view) {

try {

int value = 8 / 0;

} catch (Exception e) {

UMCrash.generateCustomLog(e, “5001”);

}

}

StackOverflowError: StackOverflowError

// Send SoF button click event: simulate stack overflow exception

public void exceptionStackOverFlow(View view) {

try {

exceptionStackOverFlow(view);

} catch (Exception e) {

UMCrash.generateCustomLog(e, “5002”);

}

}

Memory overflow exception:.outofMemoryError

// Send the OOM exception button click event: simulate the memory overflow exception, of course, OOM has other types, here to heap overflow as an example to demonstrate

public void exceptionOutOfMemory(View view) {

try {

List<byte[]> list = new ArrayList<>();

while (true) {

list.add(new byte[1024 * 1024]);

}

} catch (Exception e) {

UMCrash.generateCustomLog(e, “5003”);

}

}

Automatic reporting of exceptions

ArithmeticException: ArithmeticException

StackOverflowError is reported

OutOfMemoryError is reported

The abnormal alarm

Support email, Dingding, enterprise wechat, feishu and Webhook push.

Statistical analysis

Different types of anomalies can be carried out multidimensional statistics and analysis, we can continue to explore mining.

conclusion

Through the above process, we tested the abnormal data reporting and statistics function of mobile APP, which is actually similar to the process of data collection, transmission and analysis of Internet of Things devices. Moreover, the whole integrated process is relatively smooth, and a remote service monitoring terminal was made for our APP in a few simple steps.

After the launch of our APP, the APM service of Umeng + will be a sharp tool for our online mobile application monitoring. In addition, it is expected that Umong + will provide the official access to the Hongmeng operating system, so as to directly support the Virtual devices based on HarmonyOS in Huawei DevEco Studio, and facilitate development and debugging.

Author: Niu Xiaoqing

1. Participated in eeg pattern recognition research, teaching software, distributed Internet project and design and development of large Internet of Things platform, etc.

2. 4 years of team management experience, once built a technical team from 0 to 1, from the original 1 to the present 25 people. The projects I am responsible for have landed in many cities.

3. Responsible for team management of 20+ people, daily work task allocation, work progress tracking, work achievement reporting and internal team sharing. Intensive management, PMP project management professional certification.

4. Responsible for the company’s business platform architecture design, program compilation, fund declaration, r&d department team building, project acceptance training, external publicity, etc. Continuous output, CSDN blog expert certification.

The original link

This article is the original content of Aliyun and shall not be reproduced without permission.