Browse Source

Z991239-5139 #comment 增加录像信息上报耗时告警

80274480 1 year ago
parent
commit
d8175818f6

+ 2 - 1
Module/mod_recorder/Event.h

@@ -12,4 +12,5 @@
 #define LOG_EVT_DELETE_BIG_LOGFILE					0x31210005				//删除过大日志文件
 #define LOG_EVT_RECORDING_FAILED					0x31210006				//交易录像录制失败
 #define LOG_EVT_RECORD_ENTITY_EXCEPTION				0x31210007				//录像实体异常
-#define LOG_EVT_POST_RECORDINFO_FAILED				0x31210008				//上报录像信息失败
+#define LOG_EVT_POST_RECORDINFO_FAILED				0x31210008				//上报录像信息失败
+#define LOG_EVT_POST_RECORDINFO_COST_TIME			0x31210009				//上报录像信息耗时

+ 22 - 2
Module/mod_recorder/recordinfo.cpp

@@ -66,15 +66,35 @@ int post_video_recordinfo_list(video_record_info_t* pinfo, int itimeout, bool bp
 
 	//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("begin http get request, timeout is %d, printdbg flag is %s.", req.m_timeOut, req.m_printDbg ? "true" : "false");
 
+	unsigned int ustarttime = get_millisec_time();
+
 	RecordInfoHTTPRet ret;
 	if (client->Post(req, ret)) {
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Post result is %s, returnCode:%s, code:%s, errorMsg:%s, message:%s.",
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("post result is %s, returnCode:%s, code:%s, errorMsg:%s, message:%s.",
 			ret.m_success ? "success" : "failed", ret.m_returnCode.c_str(), ret.m_code.c_str(), ret.m_errorMsg.c_str(), ret.m_message.c_str());
+		LogWarn(Severity_Low, Error_Debug, LOG_EVT_POST_RECORDINFO_COST_TIME, CSimpleStringA::Format("post video record infos cost time is %ums.", get_millisec_time()- ustarttime).GetData());
 		iret = 0;
 	}
 	else {
-		LogWarn(Severity_Middle, Error_Exception, LOG_EVT_POST_RECORDINFO_FAILED, CSimpleStringA::Format("Post video record infos fail, url=%s, syscode=%d, usercode=%s, errmsg=%s", req.m_url.c_str(), ret.m_sysCode, ret.m_userCode.c_str(), ret.m_errMsg.c_str()).GetData());
+		LogWarn(Severity_Middle, Error_Exception, LOG_EVT_POST_RECORDINFO_FAILED, CSimpleStringA::Format("post video record infos fail, url=%s, syscode=%d, usercode=%s, errmsg=%s", req.m_url.c_str(), ret.m_sysCode, ret.m_userCode.c_str(), ret.m_errMsg.c_str()).GetData());
 	}
 
 	return iret;
+}
+
+
+unsigned int get_millisec_time()
+{
+#ifdef RVC_OS_LINUX
+	unsigned int uptime = 0;
+	struct timespec on;
+	if (clock_gettime(CLOCK_MONOTONIC, &on) == 0) {
+		uptime = on.tv_sec * 1000 + on.tv_nsec / 1000000;
+	}
+		
+	return uptime;
+
+# else
+	return GetTickCount();
+#endif
 }

+ 2 - 0
Module/mod_recorder/recordinfo.h

@@ -96,4 +96,6 @@ struct RecordInfoHTTPRet : CHTTPRet {
 
 int post_video_recordinfo_list(video_record_info_t* pinfo, int itimeout, bool bprintdbg);
 
+unsigned int get_millisec_time();
+
 #endif