8.0.17 apm 修改
This commit is contained in:
5
test/crashreport-apmbyte/src/main/AndroidManifest.xml
Normal file
5
test/crashreport-apmbyte/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.test.crashreport.apm">
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.mogo.test.crashreport.apm;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.apm.insight.AttachUserData;
|
||||
import com.apm.insight.CrashType;
|
||||
import com.apm.insight.MonitorCrash;
|
||||
import com.apm.insight.log.VLog;
|
||||
import com.bytedance.apm.insight.ApmInsight;
|
||||
import com.bytedance.apm.insight.ApmInsightInitConfig;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.test.crashreport.CrashReportConstants;
|
||||
import com.mogo.test.crashreport.ITestCrashReportProvider;
|
||||
import com.mogo.utils.AppUtils;
|
||||
import com.mogo.utils.CommonUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/9/9
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
@Route(path = CrashReportConstants.PATH)
|
||||
public class ApmCrashReportProvider implements ITestCrashReportProvider {
|
||||
private static final String BYTEAMP_APPID = "302368";
|
||||
|
||||
private static final String TAG = "ApmCrashReportProvider";
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
Logger.d(TAG, "init");
|
||||
initCrash(context);
|
||||
initApmInsight(context);
|
||||
}
|
||||
private void initCrash(final Context context) {
|
||||
|
||||
MonitorCrash crash = MonitorCrash.init(context, BYTEAMP_APPID, CommonUtils.getVersionCode(context), CommonUtils.getVersionName(context))
|
||||
.setCustomDataCallback(new AttachUserData() {
|
||||
@Override
|
||||
public Map<? extends String, ? extends String> getUserData(CrashType type) {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
//地图版本
|
||||
String mapSDKVersion = AppUtils.getCustomMapSDKVersion(context);
|
||||
map.put("MAP_SDK_VERSION", mapSDKVersion);
|
||||
return map;
|
||||
}
|
||||
});
|
||||
crash.config().setChannel("eagle");
|
||||
crash.config().setDeviceId(MoGoAiCloudClientConfig.getInstance().getSn());//可选,可以设置自定义did,不设置会使用内部默认的
|
||||
// crash.setReportUrl("www.xxx.com"); // 私有化部署:私有化部署才配置上报地址
|
||||
// crash.addTags("key", "value"); // 自定义筛选tag, 按需添加、可多次覆盖
|
||||
}
|
||||
|
||||
/**
|
||||
* ApmInsight性能监控初始化
|
||||
*/
|
||||
private void initApmInsight(Context context) {
|
||||
|
||||
ApmInsightInitConfig.Builder builder = ApmInsightInitConfig.builder();
|
||||
//设置分配的appid
|
||||
builder.aid(BYTEAMP_APPID);
|
||||
//是否开启卡顿功能
|
||||
builder.blockDetect(true);
|
||||
//是否开启严重卡顿功能
|
||||
builder.seriousBlockDetect(true);
|
||||
//是否开启流畅性和丢帧
|
||||
builder.fpsMonitor(true);
|
||||
//控制是否打开WebVeiw监控
|
||||
builder.enableWebViewMonitor(true);
|
||||
//控制是否打开内存监控
|
||||
builder.memoryMonitor(true);
|
||||
//控制是否打开电量监控
|
||||
builder.batteryMonitor(true);
|
||||
//是否打印日志,注:线上release版本要配置为false
|
||||
builder.debugMode(true);
|
||||
//支持用户自定义user_id把平台数据和自己用户关联起来,可以不配置
|
||||
// builder.userId("user_id");
|
||||
//私有化部署:配置数据上报的域名 (私有化部署才需要配置,内部有默认域名),测试支持设置http://www.xxx.com 默认是https协议
|
||||
// builder.defaultReportDomain("www.xxx.com");
|
||||
//设置渠道。1.3.16版本增加接口
|
||||
builder.channel("local");
|
||||
//打开自定义日志回捞能力,1.4.1版本新增接口
|
||||
builder.enableLogRecovery(true);
|
||||
//设置数据和Rangers Applog数据打通,设备标识did必填。1.3.16版本增加接口
|
||||
// builder.setDynamicParams(new IDynamicParams() {
|
||||
// @Override
|
||||
// public String getUserUniqueID() {
|
||||
// //可选。依赖AppLog可以通过AppLog.getUserUniqueID()获取,否则可以返回null。
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getAbSdkVersion() {
|
||||
// //可选。如果依赖AppLog可以通过AppLog.getAbSdkVersion()获取,否则可以返回null。
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getSsid() {
|
||||
// //可选。依赖AppLog可以通过AppLog.getSsid()获取,否则可以返回null。
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getDid() {
|
||||
// //1.4.0版本及以上,可选,其他版本必填。设备的唯一标识,如果依赖AppLog可以通过 AppLog.getDid() 获取,也可以自己生成。
|
||||
// return AppLog.getDid();
|
||||
// }
|
||||
// });
|
||||
ApmInsight.getInstance().init(context, builder.build());
|
||||
|
||||
//初始化自定日志,配置自定义日志最大占用磁盘,内部一般配置20,代表最大20M磁盘占用。1.4.1版本开始存在这个api
|
||||
VLog.init(context, 20);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user