[6.3.0][APM升级] 增加崩溃防护;增加主动上传Vlog接口
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package com.mogo.test.crashreport.apm;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.apm.insight.ExitType;
|
||||
import com.apm.insight.MonitorCrash;
|
||||
import com.apm.insight.log.VLog;
|
||||
import com.bytedance.apm.insight.ApmInsight;
|
||||
@@ -21,11 +23,12 @@ import com.mogo.commons.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.util.CommonUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.DeviceUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.MetaDataUtils;
|
||||
import com.mogo.test.crashreport.CrashReportConstants;
|
||||
import com.mogo.test.crashreport.ITestCrashReportProvider;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import rx.Observable;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
@@ -218,6 +221,8 @@ public class ApmCrashReportProvider implements ITestCrashReportProvider {
|
||||
})
|
||||
// 可选,添加pv事件的自定义tag,可以用来筛选崩溃率计算的分母数据
|
||||
//.pageViewTags(<<Map<String, String>>>)
|
||||
.exitType(ExitType.ALL) // 上报应用退出原因
|
||||
.crashProtect(true) // 开启崩溃防护
|
||||
.build();
|
||||
MonitorCrash monitorCrash = MonitorCrash.init(context, config);
|
||||
}
|
||||
@@ -286,10 +291,26 @@ public class ApmCrashReportProvider implements ITestCrashReportProvider {
|
||||
// }
|
||||
// });
|
||||
ApmInsight.getInstance().init(context, builder.build());
|
||||
|
||||
//初始化自定日志,配置自定义日志最大占用磁盘,内部一般配置20,代表最大20M磁盘占用。1.4.1版本开始存在这个api
|
||||
VLog.init(context, 50);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean uploadVlog(long startTime, long endTime) {
|
||||
AtomicBoolean result = new AtomicBoolean(false);
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
ApmInsightAgent.uploadVlog(startTime, endTime, (success, msg) -> {
|
||||
Log.d(TAG, "--- uploadVlog callback ---:" + success + ", msg:" + msg);
|
||||
result.set(success);
|
||||
latch.countDown();
|
||||
});
|
||||
try {
|
||||
latch.await();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return result.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.mogo.test.crashreport;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/9/9
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
public interface ITestCrashReportProvider extends IProvider {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mogo.test.crashreport
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/9/9
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
interface ITestCrashReportProvider : IProvider {
|
||||
/**
|
||||
* 上传通过[com.mogo.eagle.core.utilcode.util.VLogUtils] 类记录的日志
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
*/
|
||||
fun uploadVlog(startTime: Long, endTime: Long): Boolean
|
||||
}
|
||||
Reference in New Issue
Block a user