[3.3.0][Opt]新增弱网监测功能
This commit is contained in:
@@ -33,6 +33,7 @@ import com.tencent.matrix.trace.config.SharePluginInfo
|
||||
import com.tencent.matrix.trace.config.TraceConfig
|
||||
import com.zhjt.mogo_core_function_devatools.apm.*
|
||||
import com.mogo.eagle.core.function.api.upgrade.*
|
||||
import com.mogo.weak.network.SdtManager
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.BadCaseManager
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.consts.BadCaseConfig
|
||||
import com.zhjt.mogo_core_function_devatools.binding.*
|
||||
@@ -53,6 +54,8 @@ import com.zhjt.mogo_core_function_devatools.strict.*
|
||||
import com.zhjt.mogo_core_function_devatools.trace.TraceManager.Companion.traceManager
|
||||
import com.zhjt.mogo_core_function_devatools.tts.TtsManager.Companion.ttsManager
|
||||
import com.zhjt.mogo_core_function_devatools.upgrade.UpgradeManager.Companion.upgradeManager
|
||||
import com.zhjt.mogo_core_function_devatools.weaknetwork.DetectResultImpl
|
||||
import com.zhjt.mogo_core_function_devatools.weaknetwork.WeakNetworkStrategy
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import com.zhjt.service.chain.TracingConstants.Endpoint.Companion.PAD
|
||||
|
||||
@@ -97,6 +100,11 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
BindingCarManager.init(mContext!!)
|
||||
apmEnvProvider.init(if(DebugConfig.isDebug()) "0" else "1", "${ DebugConfig.getNetMode() }", mDockerVersion ?: "")
|
||||
BadCaseManager.init()
|
||||
if (DebugConfig.isDebug()) {
|
||||
SdtManager.init(mContext!!, true, DetectResultImpl())
|
||||
// 监听弱网
|
||||
WeakNetworkStrategy.startListen()
|
||||
}
|
||||
}
|
||||
|
||||
override fun checkMonitorDb() {
|
||||
|
||||
@@ -73,6 +73,8 @@ class TraceManager : IMoGoCloudListener, IMoGoAutopilotCarConfigListener {
|
||||
FwBuild(true, -1, pkgName + ChainConstant.CHAIN_LINK_LOG_CLOUD_WEB_SOCKET_V2N)
|
||||
fwBuildMap[ChainConstant.CHAIN_LINK_LOG_HD_MAP] =
|
||||
FwBuild(true, -1, pkgName + ChainConstant.CHAIN_LINK_LOG_HD_MAP_BIZ)
|
||||
fwBuildMap[ChainConstant.CHAIN_LINK_LOG_WEAK_NETWORK] =
|
||||
FwBuild(true, -1, pkgName + ChainConstant.CHAIN_LINK_LOG_RECORD_WEAK_NETWORK)
|
||||
|
||||
|
||||
traceInfoCache[ChainConstant.CHAIN_LINK_LOG_CONNECT_STATUS] =
|
||||
@@ -101,6 +103,8 @@ class TraceManager : IMoGoCloudListener, IMoGoAutopilotCarConfigListener {
|
||||
ChainLogParam(true, "Cloud WebSocket V2N")
|
||||
traceInfoCache[ChainConstant.CHAIN_LINK_LOG_HD_MAP] =
|
||||
ChainLogParam(true, "HD Map Caller")
|
||||
traceInfoCache[ChainConstant.CHAIN_LINK_LOG_WEAK_NETWORK] =
|
||||
ChainLogParam(true, "WeakNetWork Record")
|
||||
|
||||
FileWriteManager.getInstance()
|
||||
.init(context, MoGoAiCloudClientConfig.getInstance().sn, pkgName, fwBuildMap)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.zhjt.mogo_core_function_devatools.weaknetwork
|
||||
|
||||
import android.util.Log
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant
|
||||
import com.mogo.weak.network.StubImpl
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import com.zhjt.service.chain.TracingConstants
|
||||
|
||||
class DetectResultImpl: StubImpl.ReportDetectResultListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "DetectResultImpl"
|
||||
}
|
||||
|
||||
override fun onDetectResult(resultsJson: String?) {
|
||||
resultsJson?.let { invokeWeakResult(it) }
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = ChainConstant.CHAIN_LINK_LOG_WEAK_NETWORK,
|
||||
linkCode = ChainConstant.CHAIN_LINK_WEAK_NETWORK,
|
||||
endpoint = TracingConstants.Endpoint.PAD,
|
||||
nodeAliasCode = ChainConstant.CHAIN_ALIAS_CODE_RECORD_WEAK_NETWORK,
|
||||
paramIndexes = [0],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
private fun invokeWeakResult(jsonStr: String) {
|
||||
Log.d(TAG, jsonStr)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.zhjt.mogo_core_function_devatools.weaknetwork
|
||||
|
||||
import android.util.Log
|
||||
import com.mogo.cloud.network.WeakNetworkManager
|
||||
import com.mogo.cloud.network.WeakNetworkManager.setListener
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.weak.network.SdtManager
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import com.zhjt.service.chain.TracingConstants
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock
|
||||
|
||||
object WeakNetworkStrategy {
|
||||
|
||||
private const val TAG = "WeakNetworkStrategy"
|
||||
|
||||
// 记录到链路日志中的时间间隔
|
||||
private const val OUTPUT_TIME_INTERVAL = 15000
|
||||
|
||||
private var lastOutputTime = 0L
|
||||
|
||||
private val lock by lazy {
|
||||
ReentrantReadWriteLock()
|
||||
}
|
||||
|
||||
private val writeLock by lazy {
|
||||
lock.writeLock()
|
||||
}
|
||||
|
||||
private val readLock by lazy {
|
||||
lock.readLock()
|
||||
}
|
||||
|
||||
fun startListen() {
|
||||
setListener(object : WeakNetworkManager.OnWeakHttpListener {
|
||||
override fun onHttpRttReceived(hashCode: Int, url: String, timeStamp: Long) {
|
||||
outputLog(url, timeStamp)
|
||||
}
|
||||
|
||||
override fun onFailEvent(hashCode: Int, url: String, timeStamp: Long, currentFailCount: Long) {
|
||||
outputLog(url, timeStamp, true)
|
||||
}
|
||||
|
||||
override fun onWeakNetworkEvent() {
|
||||
// // 大而全接口干扰,需排除掉
|
||||
// Log.d(TAG, "收到弱网事件!")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun stopListen() {
|
||||
setListener(null)
|
||||
}
|
||||
|
||||
private fun outputLog(url: String, timeStamp: Long, isFail: Boolean = false) {
|
||||
ThreadUtils.getIoPool().submit {
|
||||
writeLock.lock()
|
||||
try {
|
||||
val currentTime = System.currentTimeMillis()
|
||||
if (currentTime - lastOutputTime > OUTPUT_TIME_INTERVAL) {
|
||||
invokeWeakResult("url为:$url, 耗时为:$timeStamp${if (isFail) " 连接失败!" else ""}")
|
||||
SdtManager.startActiveCheck()
|
||||
lastOutputTime = currentTime
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "out put exception:${e.message}")
|
||||
} finally {
|
||||
writeLock.unlock()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = ChainConstant.CHAIN_LINK_LOG_WEAK_NETWORK,
|
||||
linkCode = ChainConstant.CHAIN_LINK_WEAK_NETWORK,
|
||||
endpoint = TracingConstants.Endpoint.PAD,
|
||||
nodeAliasCode = ChainConstant.CHAIN_ALIAS_CODE_RECORD_WEAK_NETWORK,
|
||||
paramIndexes = [0],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
private fun invokeWeakResult(jsonStr: String) {
|
||||
Log.d(TAG, jsonStr)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user