Browse Source

!10711 T25EE871_可视柜台终端轻量化_HTTP分布式追踪优化
Merge pull request !10711 from 80374463/ST2_0311_traceToServer

杨诗友80174847 5 months ago
parent
commit
6b67a3b296
39 changed files with 690 additions and 210 deletions
  1. 1 0
      .gitignore
  2. 0 1
      DevAdapter/simulator/include/DeviceSimulator.h
  3. 5 4
      Framework/Common/IHttpFunc.h
  4. 66 13
      Framework/Common/SpBase.h
  5. 14 0
      Framework/Common/httpTrace_define.hpp
  6. 79 4
      Framework/RVCComm/HTTPClient.cpp
  7. 7 5
      Framework/RVCComm/HTTPClient.h
  8. 2 2
      Framework/RvcLogSdk/baseFun.cpp
  9. 1 1
      Framework/RvcLogSdk/log_api.cpp
  10. 2 1
      Framework/RvcRestfulSdk/RestfulFunc.h
  11. 14 1
      Framework/RvcRestfulSdk/RestfulFuncImpl.cpp
  12. 4 4
      Framework/RvcRestfulSdk/test/testNormlReqAns.cpp
  13. 1 1
      Framework/spbase/CMakeLists.txt
  14. 2 1
      Framework/spbase/SpBase.cpp
  15. 10 7
      Framework/spbase/sp_httpDefine.cpp
  16. 6 4
      Module/mod_CardIssuerStand/CardIssuerFSM.cpp
  17. 8 4
      Module/mod_CenterSetting/CenterSettingConn.cpp
  18. 2 1
      Module/mod_IDCertificate/IDCertFSM.cpp
  19. 16 11
      Module/mod_UpgradeMgr/UpgradeTaskFSM.cpp
  20. 6 3
      Module/mod_accessauth/AccessAuthFSM.cpp
  21. 2 1
      Module/mod_accessauth/mod_AccessAuth.cpp
  22. 4 3
      Module/mod_alarm/AlarmFSM.cpp
  23. 6 4
      Module/mod_cardissuerstore/CardIssuerFSM.cpp
  24. 4 1
      Module/mod_chromium/CModTools.cpp
  25. 1 1
      Module/mod_chromium/EntitySessionManager.cpp
  26. 1 1
      Module/mod_chromium/baseEx.cpp
  27. 1 1
      Module/mod_chromium/baseEx.h
  28. 2 0
      Module/mod_chromium/mod_chromium.cpp
  29. 2 1
      Module/mod_counterconnector/http_callrouter.cpp
  30. 2 2
      Module/mod_heartbeat/HeartBeatFSM.cpp
  31. 4 3
      Module/mod_mediacontroller/brightnessinfo.cpp
  32. 2 1
      Module/mod_recorder/recordinfo.cpp
  33. 10 5
      Module/mod_upload/UploadFSM.cpp
  34. 2 1
      Other/libRestfulFunc/RestfulFunc.h
  35. 15 1
      Other/libRestfulFunc/RestfulFuncImpl.cpp
  36. 4 4
      Other/libRestfulFunc/test/testNormlReqAns.cpp
  37. 221 17
      Other/libpublicFun/exLog/skyeyeLog.cpp
  38. 51 0
      Other/libpublicFun/exLog/skyeyeLog.h
  39. 110 95
      addin/res/VTMModifyHeaders/background.js

+ 1 - 0
.gitignore

@@ -197,6 +197,7 @@ compile_commands.json
 CTestTestfile.cmake
 _deps
 #CMakeSettings.json
+CMakePresets.json
 /Other/libimageproc/RCa15420
 /cpp.hint
 !/ThirdParty/Include/msgpack/msgpack/preprocessor/debug

+ 0 - 1
DevAdapter/simulator/include/DeviceSimulator.h

@@ -380,7 +380,6 @@ ErrorCodeEnum SimulatorHttpFunction(string entityName, string devFuncName)
 	HttpClientRequestConfig config(HttpRequestMethod::POST, GetSimulatorUrl().c_str(), NULL);
 	SP::Simulator::Restful::FulfillRequestJsonBody(&config, simulatorCommonReq);
 	RestfulClient client = RestfulClient::getInstance();
-
 	config.PreDo();
 	client.Do(&config, &result);
 	if (result.ResponseOK()) {

+ 5 - 4
Framework/Common/IHttpFunc.h

@@ -5,6 +5,7 @@
 
 #include <unordered_map>
 #include "RVCComm.h"
+#include "httpTrace_define.hpp"
 
 using namespace std;
 
@@ -87,13 +88,13 @@ public:
 	//销毁对象
 	virtual void Destory() = 0;
 	//get请求
-	virtual const bool Get(CHTTPReq& req, CHTTPRet& ret) = 0;
+	virtual const bool Get(CHTTPReq& req, CHTTPRet& ret, HttpClientTraceLink* pTrace) = 0;
 	//post请求
-	virtual const bool Post(CHTTPReq& req, CHTTPRet& ret) = 0;
+	virtual const bool Post(CHTTPReq& req, CHTTPRet& ret, HttpClientTraceLink* pTrace) = 0;
 	//文件块上传
-	virtual const bool UploadFileBlock(CHTTPUploadReq& req, CHTTPUploadRet& ret) = 0;
+	virtual const bool UploadFileBlock(CHTTPUploadReq& req, CHTTPUploadRet& ret, HttpClientTraceLink* pTrace) = 0;
 	//文件块下载
-	virtual const bool DownloadFileBlock(const char* url, const char* jsonReqStr, fileContentArray &content, long& httpCode, unordered_map<string, string>& responseHeaders, long timeout) = 0;
+	virtual const bool DownloadFileBlock(const char* url, const char* jsonReqStr, fileContentArray &content, long& httpCode, unordered_map<string, string>& responseHeaders, long timeout, HttpClientTraceLink* pTrace) = 0;
 };
 
 typedef void (*LogFnCallback)(const char*);

+ 66 - 13
Framework/Common/SpBase.h

@@ -57,6 +57,7 @@
 #endif // __cplusplus
 
 #include "ErrorCode.h"
+#include "httpTrace_define.hpp"
 
 #ifndef MODULE_VERSION_FULL
 	#define MODULE_VERSION_FULL  "0.0.0"
@@ -388,25 +389,24 @@ struct CLightPackInfo
 
 SPBASE_API CSimpleStringA uuid4_generateStr(int len);
 
-struct linkContext
-{
+struct linkContext {
 	CSimpleStringA bussinessId;
 	CSimpleStringA traceId;
 	CSimpleStringA spanId;
 	CSimpleStringA parentSpanId;
+	CSimpleStringA timestamp; // 新增的 timestamp 字段
 
-	linkContext():bussinessId(true), traceId(true), spanId(true), parentSpanId(true){}
-	linkContext(CSimpleStringA t_bussinessId, CSimpleStringA t_traceId, CSimpleStringA t_spanId, CSimpleStringA t_parentSpanId) {
-		bussinessId = t_bussinessId;
-		traceId = t_traceId;
-		spanId = t_spanId;
-		parentSpanId = t_parentSpanId;
+	linkContext() : bussinessId(true), traceId(true), spanId(true), parentSpanId(true) {
+		updateTimestamp(); // 初始化时生成时间戳
 	}
 
-	void Init(const char* t_bussId, const char* t_traceId, const char* t_spanId, const char* t_parentSpanId)
-	{
-		if (t_bussId && t_traceId && t_spanId && t_parentSpanId)
-		{
+	linkContext(CSimpleStringA t_bussinessId, CSimpleStringA t_traceId, CSimpleStringA t_spanId, CSimpleStringA t_parentSpanId)
+		: bussinessId(t_bussinessId), traceId(t_traceId), spanId(t_spanId), parentSpanId(t_parentSpanId) {
+		updateTimestamp(); // 初始化时生成时间戳
+	}
+
+	void Init(const char* t_bussId, const char* t_traceId, const char* t_spanId, const char* t_parentSpanId) {
+		if (t_bussId && t_traceId && t_spanId && t_parentSpanId) {
 			char copy_bussId[LINKINFO_BUSSID_LEN + 1], copy_traceId[LINKINFO_TRACEID_LEN + 1];
 			char copy_spanId[LINKINFO_SPANID_LEN + 1], copy_parentSpanId[LINKINFO_PARENTSPANID_LEN + 1];
 			memset(copy_bussId, 0, sizeof(copy_bussId));
@@ -421,21 +421,47 @@ struct linkContext
 			traceId = copy_traceId;
 			spanId = copy_spanId;
 			parentSpanId = copy_parentSpanId;
+			updateTimestamp(); // 初始化时生成时间戳
 		}
 	}
 
+	void updateTimestamp()
+	{
+		time_t timestamp_seconds = time(NULL);
+
+		// 将时间戳转换为字符串
+		timestamp = CSimpleStringA::Format("%ld", timestamp_seconds);
+	}
+	HttpClientTraceLink convertToHttpClientTraceLink()
+	{
+		HttpClientTraceLink traceLink;
+		memset(&traceLink, 0, sizeof(traceLink)); // 初始化结构体
+
+		// 复制字段数据
+		strncpy(traceLink.X_B3_BusinessId, bussinessId.GetData(), sizeof(traceLink.X_B3_BusinessId) - 1);
+		strncpy(traceLink.X_B3_TraceId, traceId.GetData(), sizeof(traceLink.X_B3_TraceId) - 1);
+		strncpy(traceLink.X_B3_SpanId, spanId.GetData(), sizeof(traceLink.X_B3_SpanId) - 1);
+		strncpy(traceLink.X_B3_ParentSpanId, parentSpanId.GetData(), sizeof(traceLink.X_B3_ParentSpanId) - 1);
+		strncpy(traceLink.X_B3_Timestamp, timestamp.GetData(), sizeof(traceLink.X_B3_Timestamp) - 1);
+
+		return traceLink; // 返回结构体副本
+	}
+
 	linkContext& operator=(const linkContext& tmp) {
 		bussinessId = tmp.bussinessId;
 		traceId = tmp.traceId;
 		spanId = tmp.spanId;
 		parentSpanId = tmp.parentSpanId;
+		timestamp = tmp.timestamp;
 		return *this;
 	}
+
 	void clear() {
 		bussinessId = "";
 		traceId = "";
 		spanId = "";
 		parentSpanId = "";
+		timestamp = "";
 	}
 
 	linkContext upgradeLink() const {
@@ -449,8 +475,9 @@ struct linkContext
 		if (bussinessId.GetLength() == 0 || traceId.GetLength() == 0)
 			return *this;
 		else {
-			spanId = uuid4_generateStr(LINKINFO_SPANID_LEN);
 			parentSpanId = spanId;
+			spanId = uuid4_generateStr(LINKINFO_SPANID_LEN);
+			updateTimestamp(); // 更新时生成时间戳
 			return *this;
 		}
 	}
@@ -464,6 +491,15 @@ struct linkContext
 		traceId = uuid4_generateStr(LINKINFO_TRACEID_LEN);
 		spanId = uuid4_generateStr(LINKINFO_SPANID_LEN);
 		parentSpanId = "0";
+		updateTimestamp(); // 自动生成时生成时间戳
+	}
+
+	void AutoGenerate(CSimpleString t_bussinessId) {
+		bussinessId = t_bussinessId;
+		traceId = uuid4_generateStr(LINKINFO_TRACEID_LEN);
+		spanId = uuid4_generateStr(LINKINFO_SPANID_LEN);
+		parentSpanId = "0";
+		updateTimestamp(); // 自动生成时生成时间戳
 	}
 };
 
@@ -1550,6 +1586,23 @@ private:
 	const DbgToBeidou& operator=(const DbgToBeidou&) { return *this; };
 };
 
+/*
+#define PROCESS_LINK_CONTEXT(linkName) \
+	linkContext linkContextVar; \
+    linkContextVar.AutoGenerate(linkName); \
+	DbgWithLink(LOG_LEVEL_E::LOG_LEVEL_DEBUG, LOG_TYPE_E::LOG_TYPE_SYSTEM)("linkContextVar, bussinessId:%s, traceId:%s, spanId:%s, parentSpanId:%s", linkContextVar.bussinessId.GetData(), linkContextVar.traceId.GetData(), linkContextVar.spanId.GetData(), linkContextVar.parentSpanId.GetData()); \
+    DbgToBeidou(linkContextVar, __FUNCTION__)(); \
+    linkContextVar.upgradeLinkAndSave(); \
+	DbgWithLink(LOG_LEVEL_E::LOG_LEVEL_DEBUG, LOG_TYPE_E::LOG_TYPE_SYSTEM)("update linkContextVar, bussinessId:%s, traceId:%s, spanId:%s, parentSpanId:%s", linkContextVar.bussinessId.GetData(), linkContextVar.traceId.GetData(), linkContextVar.spanId.GetData(), linkContextVar.parentSpanId.GetData()); \
+    HttpClientTraceLink nextLink = linkContextVar.convertToHttpClientTraceLink();
+*/
+
+#define PROCESS_LINK_CONTEXT(linkName) \
+	linkContext linkContextVar; \
+    linkContextVar.AutoGenerate(linkName); \
+	DbgToBeidou(linkContextVar, __FUNCTION__)(); \
+    linkContextVar.upgradeLinkAndSave(); \
+	HttpClientTraceLink nextLink = linkContextVar.convertToHttpClientTraceLink();
 
 class SPBASE_API DbgWithLink {
 public:

+ 14 - 0
Framework/Common/httpTrace_define.hpp

@@ -0,0 +1,14 @@
+#ifndef _HTTP_CLIENT_TRACE_HEADER_
+#define _HTTP_CLIENT_TRACE_HEADER_
+#pragma once
+#include <stdio.h>
+
+struct HttpClientTraceLink {
+    char X_B3_BusinessId[33];  // 业务ID
+    char X_B3_TraceId[33];     // 跟踪ID
+    char X_B3_SpanId[17];       // 跨度ID
+    char X_B3_ParentSpanId[17]; // 父跨度ID
+    char X_B3_Timestamp[17];    // 时间戳
+};
+
+#endif

+ 79 - 4
Framework/RVCComm/HTTPClient.cpp

@@ -665,7 +665,7 @@ const bool CHTTPClient::UploadForm(const std::string& strURL,
 /************************************************************************/
 /* add by cfq 添加文件块上传                                            */
 /************************************************************************/
-const bool CHTTPClient:: UploadFileBlock(CHTTPUploadReq &req, CHTTPUploadRet &ret)
+const bool CHTTPClient:: UploadFileBlock(CHTTPUploadReq &req, CHTTPUploadRet &ret, HttpClientTraceLink* pTrace)
 {	
 	if(req.url.empty()){
 		if (m_eSettingsFlags & ENABLE_LOG)
@@ -696,6 +696,28 @@ const bool CHTTPClient:: UploadFileBlock(CHTTPUploadReq &req, CHTTPUploadRet &re
 	/** Now specify we want to POST data */
 	curl_easy_setopt(m_pCurlSession, CURLOPT_POST, 1L);
 
+   unordered_map<string, string> m_headers;
+   if (pTrace != NULL
+		&& strlen(pTrace->X_B3_BusinessId) > 0
+		&& strlen(pTrace->X_B3_TraceId) > 0
+		&& strlen(pTrace->X_B3_SpanId) > 0
+		&& strlen(pTrace->X_B3_ParentSpanId) > 0
+		&& strlen(pTrace->X_B3_Timestamp) > 0)
+	{
+		m_headers.emplace(std::make_pair("X_B3_BusinessId", pTrace->X_B3_BusinessId));
+		m_headers.emplace(std::make_pair("X_B3_TraceId", pTrace->X_B3_TraceId));
+		m_headers.emplace(std::make_pair("X_B3_SpanId", pTrace->X_B3_SpanId));
+		m_headers.emplace(std::make_pair("X_B3_ParentSpanId", pTrace->X_B3_ParentSpanId));
+		m_headers.emplace(std::make_pair("X_B3_Timestamp", pTrace->X_B3_Timestamp));
+	}
+   std::string strHeader;
+   for (HeadersMap::const_iterator it = m_headers.cbegin();
+      it != m_headers.cend();
+      ++it)
+   {
+      strHeader = it->first + ": " + it->second; // build header string
+      AddHeader(strHeader);
+   }
 	/* stating that Expect: 100-continue is not wanted */
 	AddHeader("Expect:");
 	curl_httppost* pFormPost = NULL;
@@ -804,7 +826,7 @@ const bool CHTTPClient:: UploadFileBlock(CHTTPUploadReq &req, CHTTPUploadRet &re
 /************************************************************************/
 /* add by cfq 添加文件块下载                                            */
 /************************************************************************/
-const bool CHTTPClient:: DownloadFileBlock(const char* url, const char* jsonReqStr, fileContentArray& content, long &httpCode, unordered_map<string, string>& responseHeaders, long timeout)
+const bool CHTTPClient:: DownloadFileBlock(const char* url, const char* jsonReqStr, fileContentArray& content, long &httpCode, unordered_map<string, string>& responseHeaders, long timeout, HttpClientTraceLink* pTrace)
 {
 	if (url == nullptr)
 		return false;
@@ -822,6 +844,30 @@ const bool CHTTPClient:: DownloadFileBlock(const char* url, const char* jsonReqS
 	CheckURL(url);
 
 	if(content.copyPtr != NULL){
+      // Add headers
+      unordered_map<string, string> m_headers;
+      if (pTrace != NULL
+         && strlen(pTrace->X_B3_BusinessId) > 0
+         && strlen(pTrace->X_B3_TraceId) > 0
+         && strlen(pTrace->X_B3_SpanId) > 0
+         && strlen(pTrace->X_B3_ParentSpanId) > 0
+         && strlen(pTrace->X_B3_Timestamp) > 0)
+      {
+         m_headers.emplace(std::make_pair("X_B3_BusinessId", pTrace->X_B3_BusinessId));
+         m_headers.emplace(std::make_pair("X_B3_TraceId", pTrace->X_B3_TraceId));
+         m_headers.emplace(std::make_pair("X_B3_SpanId", pTrace->X_B3_SpanId));
+         m_headers.emplace(std::make_pair("X_B3_ParentSpanId", pTrace->X_B3_ParentSpanId));
+         m_headers.emplace(std::make_pair("X_B3_Timestamp", pTrace->X_B3_Timestamp));
+      }
+      std::string strHeader;
+      for (HeadersMap::const_iterator it = m_headers.cbegin();
+         it != m_headers.cend();
+         ++it)
+      {
+         strHeader = it->first + ": " + it->second; // build header string
+         AddHeader(strHeader);
+      }
+
 		curl_easy_setopt(m_pCurlSession, CURLOPT_HTTPPOST, 1);
 		curl_easy_setopt(m_pCurlSession, CURLOPT_POSTFIELDS, jsonReqStr);
 		//接受响应头
@@ -1483,7 +1529,7 @@ size_t CHTTPClient::RestReadCallback(void* pCurlData, size_t usBlockCount, size_
 }
 
 //add by cfq
-const bool CHTTPClient::Get(CHTTPReq &req, CHTTPRet &ret){
+const bool CHTTPClient::Get(CHTTPReq &req, CHTTPRet &ret, HttpClientTraceLink* pTrace){
 	//拼接请求参数
 	string param;
 	std::string jsonStr="";
@@ -1581,6 +1627,21 @@ const bool CHTTPClient::Get(CHTTPReq &req, CHTTPRet &ret){
 		}
 	}
 
+	if (pTrace != NULL
+		&& strlen(pTrace->X_B3_BusinessId) > 0
+		&& strlen(pTrace->X_B3_TraceId) > 0
+		&& strlen(pTrace->X_B3_SpanId) > 0
+		&& strlen(pTrace->X_B3_ParentSpanId) > 0
+		&& strlen(pTrace->X_B3_Timestamp) > 0)
+	{
+		req.m_headers.emplace(std::make_pair("X_B3_BusinessId", pTrace->X_B3_BusinessId));
+		req.m_headers.emplace(std::make_pair("X_B3_TraceId", pTrace->X_B3_TraceId));
+		req.m_headers.emplace(std::make_pair("X_B3_SpanId", pTrace->X_B3_SpanId));
+		req.m_headers.emplace(std::make_pair("X_B3_ParentSpanId", pTrace->X_B3_ParentSpanId));
+		req.m_headers.emplace(std::make_pair("X_B3_Timestamp", pTrace->X_B3_Timestamp));
+		
+	}
+
 	//set timeout
 	m_iCurlTimeout = req.m_timeOut;
 
@@ -1649,7 +1710,7 @@ const bool CHTTPClient::Get(CHTTPReq &req, CHTTPRet &ret){
 
 }
 //add by cfq
-const bool CHTTPClient::Post(CHTTPReq &req, CHTTPRet &ret){
+const bool CHTTPClient::Post(CHTTPReq &req, CHTTPRet &ret, HttpClientTraceLink* pTrace){
 
 	if(!req.m_url.empty()){
 		if(req.m_printDbg){
@@ -1712,6 +1773,20 @@ const bool CHTTPClient::Post(CHTTPReq &req, CHTTPRet &ret){
 		
 	}
 
+	if (pTrace != NULL
+		&& strlen(pTrace->X_B3_BusinessId) > 0
+		&& strlen(pTrace->X_B3_TraceId) > 0
+		&& strlen(pTrace->X_B3_SpanId) > 0
+		&& strlen(pTrace->X_B3_ParentSpanId) > 0
+		&& strlen(pTrace->X_B3_Timestamp) > 0)
+	{
+		req.m_headers.emplace(std::make_pair("X_B3_BusinessId", pTrace->X_B3_BusinessId));
+		req.m_headers.emplace(std::make_pair("X_B3_TraceId", pTrace->X_B3_TraceId));
+		req.m_headers.emplace(std::make_pair("X_B3_SpanId", pTrace->X_B3_SpanId));
+		req.m_headers.emplace(std::make_pair("X_B3_ParentSpanId", pTrace->X_B3_ParentSpanId));
+		req.m_headers.emplace(std::make_pair("X_B3_Timestamp", pTrace->X_B3_Timestamp));
+	}
+
 	//set timeout
 	m_iCurlTimeout = req.m_timeOut;
 

+ 7 - 5
Framework/RVCComm/HTTPClient.h

@@ -122,6 +122,7 @@ public:
                       std::string& strText,
                       long& lHTTPStatusCode);
 
+private:
    const bool DownloadFile(const std::string& strLocalFile,
                            const std::string& strURL,
                            long& lHTTPStatusCode);
@@ -129,7 +130,7 @@ public:
    const bool UploadForm(const std::string& strURL,
                          const PostFormInfo& data,
                          long& lHTTPStatusCode);
-
+public:
    inline void AddHeader(const std::string& strHeader)
    {
       m_pHeaderlist = curl_slist_append(m_pHeaderlist, strHeader.c_str());
@@ -147,12 +148,13 @@ public:
             const ByteBuffer& Data, HttpResponse& Response);
 
    //add by cfq  override IHttpFunc
-   virtual const bool Get(CHTTPReq &req, CHTTPRet &ret);
-   virtual const bool Post(CHTTPReq &req, CHTTPRet &ret);
-   virtual const bool UploadFileBlock(CHTTPUploadReq &req, CHTTPUploadRet &ret);
+   virtual const bool Get(CHTTPReq &req, CHTTPRet &ret, HttpClientTraceLink* pTrace);
+   virtual const bool Post(CHTTPReq &req, CHTTPRet &ret, HttpClientTraceLink* pTrace);
+   virtual const bool UploadFileBlock(CHTTPUploadReq &req, CHTTPUploadRet &ret, HttpClientTraceLink* pTrace);
    virtual const bool DownloadFileBlock(const char* url, const char* jsonReqStr, fileContentArray& content,
-	   long &httpCode, unordered_map<string, string>& responseHeaders, long timeout);
+	   long &httpCode, unordered_map<string, string>& responseHeaders, long timeout, HttpClientTraceLink* pTrace);
    
+private:
    // SSL certs
    static const std::string& GetCertificateFile() { return s_strCertificationAuthorityFile; }
    static void SetCertificateFile(const std::string& strPath) { s_strCertificationAuthorityFile = strPath; }

+ 2 - 2
Framework/RvcLogSdk/baseFun.cpp

@@ -45,7 +45,7 @@ int RvcLogSdkManager::LOG_OS_TestLogPost(const char* url, const char* body)
     config.SetJsonBody(str.c_str());
     RestfulClient client = RestfulClient::getInstance();
     config.PreDo();
-    client.Do(&config, &result);
+    client.Do(&config, &result, NULL);//Test Logs
     return 0;
 }
 int RvcLogSdkManager::SendTestLog(const char* body)
@@ -62,7 +62,7 @@ int RvcLogSdkManager::SendTestLog(const char* body)
     sendErr.SetJsonBody(jsonReq.c_str());
     RestfulClient client = RestfulClient::getInstance();
     sendErr.PreDo();
-    client.Do(&sendErr, &curResult);
+    client.Do(&sendErr, &curResult, NULL);//Test Logs
     return 0;
 }
 

+ 1 - 1
Framework/RvcLogSdk/log_api.cpp

@@ -226,7 +226,7 @@ int LOG_OS_HttpPost(const char* url,
 
 	RestfulClient client = RestfulClient::getInstance();
 	config.PreDo();
-	client.Do(&config, &result);
+	client.Do(&config, &result, NULL);//upload log should not add trace link, which will cause infinite loop
 	if (result.ResponseOK()) {
 
 		retCode = 481;

+ 2 - 1
Framework/RvcRestfulSdk/RestfulFunc.h

@@ -25,6 +25,7 @@
 #include <map>
 #include <vector>
 #include <sstream>
+#include "httpTrace_define.hpp"
 
 enum HttpRequestMethod
 {
@@ -232,7 +233,7 @@ public:
     static RestfulClient& getInstance(); // Singleton
     ~RestfulClient();
 
-    void Do(const HttpClientRequestConfig* const pRequestConfig, HttpClientResponseResult* pResponse) const;
+    void Do(const HttpClientRequestConfig* const pRequestConfig, HttpClientResponseResult* pResponse, HttpClientTraceLink* pTrace) const;
 
 private:
     RestfulClient();

+ 14 - 1
Framework/RvcRestfulSdk/RestfulFuncImpl.cpp

@@ -174,7 +174,7 @@ namespace
 #define WSTR(str) (str)
 #endif //_MSC_VER
 
-void RestfulClient::Do(const HttpClientRequestConfig* const pRequestConfig, HttpClientResponseResult* pResponse) const
+void RestfulClient::Do(const HttpClientRequestConfig* const pRequestConfig, HttpClientResponseResult* pResponse, HttpClientTraceLink* pTrace) const
 {
     http_client_config config;
     config.set_validate_certificates(pRequestConfig->NeedValidCert());
@@ -202,6 +202,19 @@ void RestfulClient::Do(const HttpClientRequestConfig* const pRequestConfig, Http
         request.headers().add(STRW("token"), STRW(token));
         request.headers().add(STRW("terminalno"), STRW(terminalno));
     }
+    if (pTrace != NULL
+        && strlen(pTrace->X_B3_BusinessId) > 0
+        && strlen(pTrace->X_B3_TraceId) > 0
+        && strlen(pTrace->X_B3_SpanId) > 0
+        && strlen(pTrace->X_B3_ParentSpanId) > 0
+        && strlen(pTrace->X_B3_Timestamp) > 0)
+    {
+        request.headers().add(STRW("X_B3_BusinessId"), STRW(pTrace->X_B3_BusinessId));
+        request.headers().add(STRW("X_B3_TraceId"), STRW(pTrace->X_B3_BusinessId));
+        request.headers().add(STRW("X_B3_SpanId"), STRW(pTrace->X_B3_BusinessId));
+        request.headers().add(STRW("X_B3_ParentSpanId"), STRW(pTrace->X_B3_BusinessId));
+        request.headers().add(STRW("X_B3_Timestamp"), STRW(pTrace->X_B3_BusinessId));
+    }
 
     if (pRequestConfig->GetRequestType() != HttpRequestMethod::GET) {
         request.set_body(STRW(pRequestConfig->GetBodyContent()), STRW(pRequestConfig->GetContentType()));

+ 4 - 4
Framework/RvcRestfulSdk/test/testNormlReqAns.cpp

@@ -8,7 +8,7 @@ TEST_CASE("test api manage", "[restful]")
     HttpClientResponseResult result;
     config.SetChildUri("/api/manage/regist/7555980103");
     RestfulClient client = RestfulClient::getInstance();
-    client.Do(&config, &result);
+    client.Do(&config, &result, NULL);
     std::cout << result.content << std::endl;
     REQUIRE(!result.content.empty());
 }
@@ -20,7 +20,7 @@ TEST_CASE("test  api stage get api", "[restful]")
     config.SetChildUri("/api/stage");
     config.AppendQuery("terminalNo", "7555980001");
     RestfulClient client = RestfulClient::getInstance();
-    client.Do(&config, &result);
+    client.Do(&config, &result, NULL);
     std::cout << result.content << std::endl;
     REQUIRE(!result.content.empty());
 }
@@ -33,7 +33,7 @@ TEST_CASE("test  api stage post api", "[restful]")
     config.SetJsonBody("{\"terminalNo\":\"7555980001\", \"errEntityList\":\"566666\"}");
     RestfulClient client = RestfulClient::getInstance();
     HttpClientResponseResult result;
-    client.Do(&config, &result);
+    client.Do(&config, &result, NULL);
     std::cout << result.content << std::endl;
     REQUIRE(!result.content.empty());
 }
@@ -47,7 +47,7 @@ TEST_CASE("test  api stage upload api", "[restful]")
     RestfulClient client = RestfulClient::getInstance();
     HttpClientResponseResult result;
     config.PreDo();
-    client.Do(&config, &result);
+    client.Do(&config, &result, NULL);
     std::cout << result.content << std::endl;
     REQUIRE(!result.content.empty());
 }

+ 1 - 1
Framework/spbase/CMakeLists.txt

@@ -1,7 +1,7 @@
 set(MODULE_NAME "spbase")
 set(MODULE_PREFIX "SPBASE")
 
-file(GLOB ${MODULE_PREFIX}_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h" "*.cpp" "*.c")
+file(GLOB ${MODULE_PREFIX}_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h" "*.cpp" "*.c" "*.hpp")
 
 list(REMOVE_ITEM ${MODULE_PREFIX}_SRCS
     "SpVitualDevice.h" 

+ 2 - 1
Framework/spbase/SpBase.cpp

@@ -41,6 +41,7 @@
 #include <winpr/locale.h>
 #include <winpr/exception.h>
 #include "uuid4.h"
+#include <chrono>
 
 
 #ifndef RVC_OS_WIN
@@ -929,4 +930,4 @@ CSimpleStringA uuid4_generateStr(int len)
 {
 	auto ret = uuid4_generate(len);
 	return ret.c_str();
-}
+}

+ 10 - 7
Framework/spbase/sp_httpDefine.cpp

@@ -506,8 +506,8 @@ DWORD getTerminalCfgInfoThread(LPVOID param)
 	TerminalCfgReq* req = (TerminalCfgReq*)param;
 	IHttpFunc* http_client = create_http(LogCallback);
 	if (http_client != NULL) {
-
-		bool ret = http_client->Post(*req, req->ret);
+		PROCESS_LINK_CONTEXT("LR0402000GetTerminalCfg")
+		bool ret = http_client->Post(*req, req->ret, &nextLink);
 		http_client->Destory();
 		if (!ret)
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("getTerminalCfgInfoThread failed, url:%s, terminalNo:%s, center_version:%s, root_version:%s",
@@ -524,7 +524,8 @@ DWORD getVTMErrMsgCfgInfoThread(LPVOID param)
 	VTMErrMsgCfgReq* req = (VTMErrMsgCfgReq*)param;
 	IHttpFunc* http_client = create_http(LogCallback);
 	if (http_client != NULL) {
-		bool ret = http_client->Post(*req, req->ret);
+		PROCESS_LINK_CONTEXT("LR0402000GetVTMErrCfg")
+		bool ret = http_client->Post(*req, req->ret, &nextLink);
 		http_client->Destory();
 		if (!ret)
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("getVTMErrMsgCfgInfoThread failed, url:%s, terminalNo:%s, page_num:%d",
@@ -542,7 +543,8 @@ DWORD getTokenThread(LPVOID param)
 
 	IHttpFunc* http_client = create_http(LogCallback);
 	if (http_client != NULL) {
-		bool ret = http_client->Post(*req, req->ret);
+		PROCESS_LINK_CONTEXT("LR0402000GetToken")
+		bool ret = http_client->Post(*req, req->ret, &nextLink);
 		http_client->Destory();
 		if (ret && req->ret.m_token.length() > 0)
 		{
@@ -674,7 +676,8 @@ std::pair<bool, VTMErrMsgCfgRet> GetVTMErrMsgCfgFromUrl(CSimpleString url, const
 
 		IHttpFunc* http_client = create_http(LogCallback);
 		if (http_client != NULL) {
-			ret = http_client->Post(req, req.ret);
+			PROCESS_LINK_CONTEXT("LR0402000GetVTMErrCfg")
+			ret = http_client->Post(req, req.ret, &nextLink);
 			http_client->Destory();
 			if (!ret)
 			{
@@ -765,8 +768,8 @@ DWORD uploadTerminalVersionThread(LPVOID param)
 	TerminalVerUpdateRet dst;
 	IHttpFunc* http_client = create_http(LogCallback);
 	if (http_client != NULL) {
-
-		bool ret = http_client->Post(*req, dst);
+		PROCESS_LINK_CONTEXT("LR0402000UploadTerminalVersion")
+		bool ret = http_client->Post(*req, dst, &nextLink);
 		http_client->Destory();
 		if (!ret)
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("uplaodTerminalVersionThread failed, url:%s, terminalNo:%s, rootVer:%s, centerVer:%s",

+ 6 - 4
Module/mod_CardIssuerStand/CardIssuerFSM.cpp

@@ -4440,7 +4440,8 @@ bool CCardIssuerFSM::RegistCardWhileCaptureCard(CSimpleStringA cardno)
 		csDate.GetData(), csTime.GetData(), cardno.GetLength(), cardno.SubString(0, 6).GetData(),
 		cardno.SubString(cardno.GetLength() - 4, 4).GetData(), m_captureReason.GetData());
 	long beg = GetTickCountRVC();
-	bool ret = client->Post(qRegistCardReq, qRegistCardRet);
+	PROCESS_LINK_CONTEXT("LR0402203RegisterCard")
+	bool ret = client->Post(qRegistCardReq, qRegistCardRet, &nextLink);
 	long end = GetTickCountRVC();
 	if (ret)
 	{
@@ -4534,8 +4535,8 @@ bool CCardIssuerFSM::SyncMaterialCount(IHttpFunc* client,SyncMaterialCountInfo s
 		pReq2.CardPercent = syncInfo.arrCardPercent[i];
 		qTempReq.reqData.push_back(pReq2);
 	}
-
-	if (!client->Post(qTempReq, qTempRet)) {
+	PROCESS_LINK_CONTEXT("LR0402203SyncMaterialCount")
+	if (!client->Post(qTempReq, qTempRet, &nextLink)) {
 		LogWarn(Severity_Middle, Error_Exception, CardIssuer_UserErrorCode_SyncMaterialCount_Failed, CSimpleStringA::Format("<SyncMaterialCount>, http req fail,url=%s, err=%s", qTempReq.m_url.c_str(), qTempRet.m_errMsg.c_str()).GetData());
 		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402203Z02").setResultCode("RTA2330")("同步物料计数通讯失败");
 		return false;//通讯失败
@@ -5154,7 +5155,8 @@ int CCardIssuerFSM::JudgeCardType(CSimpleStringA cardno, bool& bMismatch)
 	qCardTypeReq.BODY.x1.xEacNbr = cardno.GetData();
 	qCardTypeReq.BODY.x1.xIacNbr = "";
 	long beg = GetTickCountRVC();
-	bool ret = client->Post(qCardTypeReq, qCardTypeRet);
+	PROCESS_LINK_CONTEXT("LR0402203CardType")
+	bool ret = client->Post(qCardTypeReq, qCardTypeRet, &nextLink);
 	long end = GetTickCountRVC();
 	if (ret)
 	{

+ 8 - 4
Module/mod_CenterSetting/CenterSettingConn.cpp

@@ -487,7 +487,8 @@ void CenterSettingsMicroServiceHelper::UpdateVersion()
 	GetTimeoutValue(sReq.m_timeOut);
 	
 	//IHttpFunc* m_pHttpFunc = create_http(HTTPLogCallback);
-	bool ret =  m_pHttpFunc->Post(sReq, sResponse);
+    PROCESS_LINK_CONTEXT("LR0402101UploadVersion")
+	bool ret =  m_pHttpFunc->Post(sReq, sResponse, &nextLink);
 
 	if(ret && sResponse.m_success)
 	{
@@ -523,8 +524,9 @@ void CenterSettingsMicroServiceHelper::UpdateVersion()
     SP::Module::Restful::FulfillRequestJsonBody(&config, updateVersionReq);
 
     RestfulClient client = RestfulClient::getInstance();
+    PROCESS_LINK_CONTEXT("LR0402101UpdateVersion");
     config.PreDo();
-    client.Do(&config, &result);
+    client.Do(&config, &result, &nextLink);
 
     DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("返回内容为 %s", result.content.length() > 1000 ? result.content.substr(0, 1000).c_str() : result.content.c_str());
 
@@ -617,7 +619,8 @@ void CenterSettingsMicroServiceHelper::GetTimeoutValue(int& timeout)
 #ifdef RVC_OS_WIN
 int CenterSettingsMicroServiceHelper::OnRequest(CenterSettingReq& req, CenterSettingResponse& res, string& errMsg)
 {
-	bool ret = m_pHttpFunc->Post(req, res);
+    PROCESS_LINK_CONTEXT("LR0402101SyncCenter")
+	bool ret = m_pHttpFunc->Post(req, res, &nextLink);
 
 	if(ret && res.m_success)
 	{
@@ -711,8 +714,9 @@ int CenterSettingsMicroServiceHelper::GetCenterSettingsFromHttp(CenterSettingReq
     Dbg("Geting centtersetting...");
 
     RestfulClient client = RestfulClient::getInstance();
+    PROCESS_LINK_CONTEXT("LR0402101GetCenterSetting");
     config.PreDo();
-    client.Do(&config, &result);
+    client.Do(&config, &result, &nextLink);
 
     Dbg("ret result.ResponseOK() = %d.", result.ResponseOK());
     if (!result.ResponseOK()) {

+ 2 - 1
Module/mod_IDCertificate/IDCertFSM.cpp

@@ -128,7 +128,8 @@ struct ImgChekTask : ITaskSp
 		imgCheckReq.imageBase64 = encodeIn;
 		imgCheckReq.m_url = m_fsm->checkImgURL;
 		long beg = GetTickCount();
-		bool ret = client->Post(imgCheckReq, imgCheckRet);
+		PROCESS_LINK_CONTEXT("LR0402201ImgCheck")
+		bool ret = client->Post(imgCheckReq, imgCheckRet, &nextLink);
 		long end = GetTickCount();
 
 		CSimpleStringA errMsg;

+ 16 - 11
Module/mod_UpgradeMgr/UpgradeTaskFSM.cpp

@@ -133,8 +133,8 @@ namespace Task
 			if(m_fsm->m_PrintHttpLog){
 				qTempReq.m_printDbg = true;
 			}
-
-			if(!client->Post(qTempReq, qTempRet)){
+			PROCESS_LINK_CONTEXT("LR0402506SendSM3")
+			if(!client->Post(qTempReq, qTempRet, &nextLink)){
 				LogWarn(Severity_Middle, Error_Exception, ERR_TASK_SEND_SM3_HASH_FAIL,CSimpleStringA::Format("SendSM3Task http req fail,url=%s, err=%s",qTempReq.m_url.c_str(),qTempRet.m_errMsg.c_str()).GetData());
 				return false;//失败
 			}
@@ -260,7 +260,8 @@ namespace Task
 			}
 			DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("UpdateTaskStatus req=%s",qTempReq.m_reqStr.c_str());
 
-			if(!client->Post(qTempReq, qTempRet)){
+			PROCESS_LINK_CONTEXT("LR0402506UpdateTaskStatus")
+			if(!client->Post(qTempReq, qTempRet, &nextLink)){
 				LogWarn(Severity_Middle, Error_Exception, ERR_TASK_UPDATE_TASK_STATUS_FAIL,CSimpleStringA::Format("UpdateTaskStatus http req fail, upgradeTaskId=%s, url=%s, err=%s",m_fsm->m_currentTask.upgradeTaskId.GetData(),qTempReq.m_url.c_str(),qTempRet.m_errMsg.c_str()).GetData());
 				return false;//失败
 			}
@@ -386,7 +387,8 @@ namespace Task
 				qTempReq.m_printDbg = true;
 			}
 
-			if(!client->Post(qTempReq, qTempRet)){
+			PROCESS_LINK_CONTEXT("LR0402506QueryCurrTask")
+			if(!client->Post(qTempReq, qTempRet, &nextLink)){
 				LogWarn(Severity_Middle, Error_Exception, ERR_TASK_QUERY_CURR_TASK_FAIL,CSimpleStringA::Format("QueryCurrTask http req fail,url=%s, err=%s",qTempReq.m_url.c_str(),qTempRet.m_errMsg.c_str()).GetData());
 				return false;//失败
 			}
@@ -749,8 +751,8 @@ namespace Task
 			if(m_fsm->m_PrintHttpLog){
 				qTempReq.m_printDbg = true;
 			}
-
-			if(!client->Post(qTempReq, qTempRet)){
+			PROCESS_LINK_CONTEXT("LR0402506QueryNewPreTask")
+			if(!client->Post(qTempReq, qTempRet, &nextLink)){
 				if (qTempRet.m_sysCode == 6) {
 					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(UpgradeMgr_PerTask_HTTP_ERR).setResultCode("RTA5651")("终端查询任务域名解析失败");
 				}else if(qTempRet.m_sysCode == 28){
@@ -887,8 +889,8 @@ namespace Task
 			if(m_fsm->m_PrintHttpLog){
 				qTempReq.m_printDbg = true;
 			}
-
-			if(!client->Post(qTempReq, qTempRet)){
+			PROCESS_LINK_CONTEXT("LR0402506QueryNewContinueTask")
+			if(!client->Post(qTempReq, qTempRet, &nextLink)){
 				LogWarn(Severity_Middle, Error_Exception, ERR_TASK_QUERY_CONTINUE_NEW_TASK_FAIL,CSimpleStringA::Format("QueryNewContinueTask http req fail,url=%s, err=%s",qTempReq.m_url.c_str(),qTempRet.m_errMsg.c_str()).GetData());
 				return 0;//查询失败,继续查询
 			}
@@ -1230,8 +1232,8 @@ namespace Task
 			if(m_fsm->m_PrintHttpLog){
 				qTempReq.m_printDbg = true;
 			}
-
-			if(!client->Post(qTempReq, qTempRet)){
+			PROCESS_LINK_CONTEXT("LR0402506QueryTaskStatus")
+			if(!client->Post(qTempReq, qTempRet, &nextLink)){
 				LogWarn(Severity_Middle, Error_Exception, ERR_TASK_QUERY_TASK_STATUS_FAIL,CSimpleStringA::Format("QueryTaskStatus http req fail,upgradeTaskId=%s, url=%s, err=%s",m_fsm->m_currentTask.upgradeTaskId.GetData(), qTempReq.m_url.c_str(), qTempRet.m_errMsg.c_str()).GetData());
 				return false;//失败
 			}
@@ -1503,7 +1505,10 @@ namespace Task
 			content.maxLen = m_fsm->m_newEachDownloadLen;
 			int retlen = 0;
 			content.curLen = &retlen;
-			if(!client->DownloadFileBlock(downloadUrl.GetData(),jsonReq.c_str(), content,httpCode,responseHeaders,time_out)){
+			PROCESS_LINK_CONTEXT("LR0402506DownloadFile")
+
+
+			if(!client->DownloadFileBlock(downloadUrl.GetData(),jsonReq.c_str(), content,httpCode,responseHeaders,time_out, &nextLink)){
 				if (retlen > m_fsm->m_newEachDownloadLen) {
 					CSimpleStringA errMsg = CSimpleStringA::Format("retlen is over limit_length ,retlen= %d", retlen).GetData();
 					LogWarn(Severity_Middle, Error_Exception, ERR_TASK_DOWNLOAD_PACK_FAIL, CSimpleStringA::Format("DownloadPackTask http req fail, %s, url=%s", errMsg.GetData(), downloadUrl.GetData()).GetData());

+ 6 - 3
Module/mod_accessauth/AccessAuthFSM.cpp

@@ -143,6 +143,7 @@ struct TimeSynTask : ITaskSp
 		config.SetChildUri("/api/v3/sessionkey");
 		SP::Module::Restful::FulfillRequestJsonBody(&config, timeSyncReq);
 		RestfulClient client = RestfulClient::getInstance();
+		PROCESS_LINK_CONTEXT("LR0402502SessionKey");
 
 		if (m_fsm->containsChinese(m_fsm->GetmAccessAuthHost().GetData()))
 		{
@@ -161,7 +162,7 @@ struct TimeSynTask : ITaskSp
 		test = config.GetRequestUri();
 
 		config.PreDo();
-		client.Do(&config, &result);
+		client.Do(&config, &result, &nextLink);
 
 		if (result.ResponseOK()) {
 			SP::Module::Restful::CommResponseJson responseStatus;
@@ -306,9 +307,10 @@ struct UpdateWKTask : ITaskSp
 		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("请求地址:%s.", test.c_str());
 
 		RestfulClient client = RestfulClient::getInstance();
+		PROCESS_LINK_CONTEXT("LR0402502wkUpdate");
 		config.PreDo();
 		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("to Post with new restful....");
-		client.Do(&config, &result);
+		client.Do(&config, &result, &nextLink);
 		if (result.ResponseOK()) {
 			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("UpdateWKTask Connect With Restful Success.");
 			SP::Module::Restful::CommResponseJson responseStatus;
@@ -398,9 +400,10 @@ struct GetTokenTask : ITaskSp
 
 		SP::Module::Restful::FulfillRequestJsonBody(&config, getTokenReq);
 		RestfulClient client = RestfulClient::getInstance();
+		PROCESS_LINK_CONTEXT("LR0402502Access");
 		config.PreDo();
 
-		client.Do(&config, &result);
+		client.Do(&config, &result, &nextLink);
 		if (result.ResponseOK()) {
 			SP::Module::Restful::CommResponseJson responseStatus;
 			SP::Module::Restful::GetStatusFromDebranchResponse(result.content, responseStatus);

+ 2 - 1
Module/mod_accessauth/mod_AccessAuth.cpp

@@ -74,9 +74,10 @@ struct InitializerInitMKTask : ITaskSp
 		config.SetChildUri("/api/v6/initmk");
 		SP::Module::Restful::FulfillRequestJsonBody(&config, instanceReq);
 		RestfulClient client = RestfulClient::getInstance();
+		PROCESS_LINK_CONTEXT("LR0402502Initmk");
 		config.PreDo();
 
-		client.Do(&config, &result);
+		client.Do(&config, &result, &nextLink);
 		if (result.ResponseOK()) {
 			SP::Module::Restful::CommResponseJson responseStatus;
 			SP::Module::Restful::GetStatusFromDebranchResponse(result.content, responseStatus);

+ 4 - 3
Module/mod_alarm/AlarmFSM.cpp

@@ -97,8 +97,8 @@ namespace Task
 			}
 			qTempReq.m_url=m_fsm->m_sendUrl.GetData();//访问地址
 			//DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM)("alarm send =%s",qTempReq.m_reqStr.c_str());
-
-			if(!client->Post(qTempReq, qTempRet)){
+			PROCESS_LINK_CONTEXT("LR0402107SendAlarmTask")
+			if(!client->Post(qTempReq, qTempRet, &nextLink)){
 				DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("SendAlarmTask http req fail,url=%s",qTempReq.m_url.c_str());
 				return false;//失败
 			}
@@ -155,8 +155,9 @@ namespace Task
 			}
 			config.SetJsonBody(reqStr);
 			RestfulClient client = RestfulClient::getInstance();
+			PROCESS_LINK_CONTEXT("LR0402107SendAlarmTask");
 			config.PreDo();
-			client.Do(&config, &result);
+			client.Do(&config, &result, &nextLink);
 			//判断结果
 			if(result.ResponseOK()){
 				//解析返回字符串

+ 6 - 4
Module/mod_cardissuerstore/CardIssuerFSM.cpp

@@ -5124,7 +5124,8 @@ bool CCardIssuerFSM::RegistCardWhileCaptureCard(CSimpleStringA cardno)
 
 
 	long beg = GetTickCountRVC();
-	bool ret = client->Post(qRegistCardReq, qRegistCardRet);
+	PROCESS_LINK_CONTEXT("LR0402203RegisterCard")
+	bool ret = client->Post(qRegistCardReq, qRegistCardRet, &nextLink);
 	long end = GetTickCountRVC();
 	if (ret)
 	{
@@ -5202,8 +5203,8 @@ bool CCardIssuerFSM::SyncMaterialCount(IHttpFunc* client,SyncMaterialCountInfo s
 		pReq2.CardPercent = syncInfo.arrCardPercent[i];
 		qTempReq.reqData.push_back(pReq2);
 	}
-
-	if (!client->Post(qTempReq, qTempRet)) {
+	PROCESS_LINK_CONTEXT("LR0402203SyncMaterialCount")
+	if (!client->Post(qTempReq, qTempRet, &nextLink)) {
 		LogWarn(Severity_Middle, Error_Exception, CardIssuerStore_UserErrorCode_SyncMaterialCount_Failed, CSimpleStringA::Format("<SyncMaterialCount>, http req fail,url=%s, err=%s", qTempReq.m_url.c_str(), qTempRet.m_errMsg.c_str()).GetData());
 		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402220A1").setResultCode("RTA2W30")("同步物料计数通讯失败");
 		return false;//通讯失败
@@ -7097,7 +7098,8 @@ int CCardIssuerFSM::JudgeCardType(CSimpleStringA cardno, bool& bMismatch)
 	qCardTypeReq.BODY.x1.xEacNbr = cardno.GetData();
 	qCardTypeReq.BODY.x1.xIacNbr = "";
 	long beg = GetTickCountRVC();
-	bool ret = client->Post(qCardTypeReq, qCardTypeRet);
+	PROCESS_LINK_CONTEXT("LR0402203CardType")
+	bool ret = client->Post(qCardTypeReq, qCardTypeRet, &nextLink);
 	long end = GetTickCountRVC();
 	if (ret)
 	{

+ 4 - 1
Module/mod_chromium/CModTools.cpp

@@ -513,6 +513,9 @@ namespace Chromium {
     {
         CSimpleStringA strChromiumPath = GetCefHead(this->m_pEntity), strCmdLine = "";
         strCmdLine.Append(strChromiumPath).Append(" --url=").Append(mainUrl.c_str());
+
+		if (ConfigManager::getInstance().m_withUnsafeMain)
+			strCmdLine.Append(" --allow-running-insecure-content");
 		if (ConfigManager::getInstance().m_extension_debugOpen)
 			strCmdLine.Append(" --right-menu");
 		if (ConfigManager::getInstance().m_extension_withTerminal && ConfigManager::getInstance().m_extension_headerStr.length() > 0)
@@ -553,7 +556,7 @@ namespace Chromium {
 #if defined(_MSC_VER)
 		return generateCefclientCmd(false, mainUrl);
 #else
-        return generateBrowserCMDForEverything(mainUrl, 0, false);
+        return generateBrowserCMDForEverything(mainUrl, 0, ConfigManager::getInstance().m_withUnsafeMain);
 #endif //_MSC_VER
 	}
 

+ 1 - 1
Module/mod_chromium/EntitySessionManager.cpp

@@ -451,7 +451,7 @@ namespace Chromium {
 
 		root["headers"] = headers;
 		root["debug_mode"] = true;
-		root["use_url_contains"] = false;
+		root["use_url_excepts"] = true;
 
 		Json::StyledWriter writer;
 		std::string output = writer.write(root);

+ 1 - 1
Module/mod_chromium/baseEx.cpp

@@ -949,7 +949,7 @@ ConfigManager& ConfigManager::getInstance() {
 ConfigManager::ConfigManager()
 	: m_iTcpBridgePort(4504), m_strCustomMainUrl(""), m_strCustomAdUrl(""), m_runAd(false), m_runMain(false), m_runExtend(false), m_runLogin(false), m_withBrowser(false), m_withMin(false), m_withClose(false)
 	, m_withDebugMode(false), m_withMagic(false), m_withNoFileLog(false), m_installMode(false), m_withMedia(false), m_withSpecialTest(false), m_withConsole(false),
-	m_withLinkLog(false), m_withUnsafeAd(false), m_noStartupPage(false),  m_extension_debugOpen(false), m_extension_withTerminal(false)
+	m_withLinkLog(false), m_withUnsafeAd(false), m_withUnsafeMain(false), m_noStartupPage(false),  m_extension_debugOpen(false), m_extension_withTerminal(false)
 {
 	void* logProducer = nullptr;
 	std::map<std::string, void*> g_logProducerArr;

+ 1 - 1
Module/mod_chromium/baseEx.h

@@ -214,7 +214,7 @@ public:
 	std::string m_strCustomMainUrl, m_strCustomAdUrl;
 	bool m_runAd/*广告*/, m_runMain/*业务*/, m_runExtend/*低柜副屏*/, m_runLogin/*用户桌面,可能木有用*/, m_withBrowser/*是否需要与browser交互*/;
 	bool m_withDebugMode/*是否启动debug模式*/, m_withMagic/*启用随机共享内存*/, m_withNoFileLog/*是否不需要本地日志落盘*/, m_withMedia/*开启多媒体选项*/;
-	bool m_withUnsafeAd/*Ad页面忽略安全选项*/;
+	bool m_withUnsafeAd/*Ad页面忽略安全选项*/, m_withUnsafeMain/*业务页面忽略安全选项*/;
 	bool m_withConsole;
 	bool m_withSpecialTest/*开启一些终端功能的测试*/, m_withLinkLog/*开启链路中的中间链路日志*/;
 	bool m_withMin, m_withClose, m_installMode, m_existRootIni;

+ 2 - 0
Module/mod_chromium/mod_chromium.cpp

@@ -382,6 +382,8 @@ namespace Chromium {
 								ConfigManager::getInstance().m_withMedia = true;
 							else if (!trimStr.Compare("with_unsafe_ad", true))
 								ConfigManager::getInstance().m_withUnsafeAd = true;
+							else if (!trimStr.Compare("with_unsafe_main", true))
+								ConfigManager::getInstance().m_withUnsafeMain = true;
 							else if (!trimStr.Compare("with_specialTest", true))//chromium will run specical test
 								ConfigManager::getInstance().m_withSpecialTest = true;
 							else if (!trimStr.Compare("with_LinkLog", true))//control do_sendJson to print more logs(request)

+ 2 - 1
Module/mod_counterconnector/http_callrouter.cpp

@@ -96,7 +96,8 @@ node_list_head_t* get_http_callroute_list(http_call_info_t* pinfo, int itimeout,
 	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");
 
 	CallRouteHTTPRet ret;
-	if (client->Get(req, ret)) {
+	PROCESS_LINK_CONTEXT("LR0402304CallRoute")
+	if (client->Get(req, ret, &nextLink)) {
 		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Get result is %s, returnCode:%s, code:%s, errorMsg:%s, message:%s, terminalNo:%s, branchNo:%s, accessNum:%s, voiceGateAddress:%s, mediaGateAddress:%s, voiceGateAddressBackUp:%s, mediaGateAddressBackUp:%s, queueName:%s, clientLevel:%d.",
 		//	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(), 
 		//	ret.m_call_route.m_terminalNo.c_str(), ret.m_call_route.m_branchNo.c_str(), ret.m_call_route.m_accessNum.c_str(),ret.m_call_route.m_voiceGateAddress.c_str(), 

+ 2 - 2
Module/mod_heartbeat/HeartBeatFSM.cpp

@@ -449,8 +449,8 @@ bool CHeartBeatFSM::HandShakeHttp(IHttpFunc* client,bool &isHeartBeatOk) {
 
 
 	//qTempReq.m_printDbg = true;
-
-	if (!client->Post(qTempReq, qTempRet)) {
+	PROCESS_LINK_CONTEXT("LR0402503HandShake")
+	if (!client->Post(qTempReq, qTempRet, &nextLink)) {
 		LogWarn(Severity_Low, Error_Exception, LOG_EVT_HEARTBEAT_HTTP_ERROR, CSimpleStringA::Format("HandShakeHttp http req fail,url=%s, err=%s", qTempReq.m_url.c_str(), qTempRet.m_errMsg.c_str()).GetData());
 		return false;//通讯失败
 	}

+ 4 - 3
Module/mod_mediacontroller/brightnessinfo.cpp

@@ -59,9 +59,10 @@ int post_camera_brightness_info_list(unsigned int& uposttime, CSimpleStringA& er
 	unsigned int ustarttime = SP::Module::Comm::RVCGetTickCount();
 
 	BrightnessInfoHTTPRet ret;
-	if (client->Post(req, ret)) {
-		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("url:%s, post result is %s, returnCode:%s, code:%s, errorMsg:%s, message:%s.",
-		//	ret.m_success ? "success" : "failed", req.m_url.c_str(), ret.m_returnCode.c_str(), ret.m_code.c_str(), ret.m_errorMsg.c_str(), ret.m_message.c_str());
+	PROCESS_LINK_CONTEXT("LR0402208BringnessInfo")
+	if (client->Post(req, ret, &nextLink)) {
+		//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());
 		uposttime = SP::Module::Comm::RVCGetTickCount() - ustarttime;
 		iret = 0;
 	}

+ 2 - 1
Module/mod_recorder/recordinfo.cpp

@@ -71,7 +71,8 @@ int post_video_recordinfo_list(unsigned int& uposttime, CSimpleStringA& errormsg
 	unsigned int ustarttime = SP::Module::Comm::RVCGetTickCount();
 
 	RecordInfoHTTPRet ret;
-	if (client->Post(req, ret)) {
+	PROCESS_LINK_CONTEXT("LR0402312Record")
+	if (client->Post(req, ret, &nextLink)) {
 	/*	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());*/
 		uposttime = SP::Module::Comm::RVCGetTickCount() - ustarttime;

+ 10 - 5
Module/mod_upload/UploadFSM.cpp

@@ -345,7 +345,8 @@ namespace Task
 			if (m_fsm->m_currUploadFile->lastMD5Str.length() != 0) {
 				LogWarn(Severity_Low, Error_Unexpect, LOG_WARN_UPLOAD_FILE_INFO, CSimpleStringA::Format("upload %s file size is %s byte,sm3 digest is %s.", m_fsm->m_currUploadFile->fileName.c_str(), lastFileLength.c_str(), m_fsm->m_currUploadFile->lastMD5Str.c_str()).GetData());
 			}
-			if (!client->UploadFileBlock(qTempReq, qTempRet)) {
+			PROCESS_LINK_CONTEXT("LR0402104UploadFile")
+			if (!client->UploadFileBlock(qTempReq, qTempRet, &nextLink)) {
 				DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("uploadFile http req fail ,url =%s ,fileName = %s",httpUrl.c_str(), m_fsm->m_currUploadFile->fileName.c_str());
 				return false;
 			}
@@ -404,7 +405,8 @@ namespace Task
 			//qTempReq.m_printDbg = true;
 			qTempReq.m_url=m_fsm->m_centerUrl.queryTempFileUrl;//访问地址
 
-			if(!client->Post(qTempReq, qTempRet)){
+			PROCESS_LINK_CONTEXT("LR0402104QueryTempFile")
+			if(!client->Post(qTempReq, qTempRet, &nextLink)){
 				DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("queryTempFile http req fail ,fileName = %s, err=%s",m_fsm->m_currUploadFile->filePath.c_str(),qTempRet.m_errMsg.c_str());
 				return false;
 			}
@@ -472,7 +474,8 @@ namespace Task
 			updateStateReq.m_reqStr = jsonReq;//请求参数
 			updateStateReq.m_url=m_fsm->m_centerUrl.updateStateUrl;//访问地址
 
-			if(!client->Post(updateStateReq, updateStateRet)){
+			PROCESS_LINK_CONTEXT("LR0402104UpdateState")
+			if(!client->Post(updateStateReq, updateStateRet, &nextLink)){
 				DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("updateState is fail, userCode = %s, errmsg = %s",updateStateRet.m_userCode.c_str(), updateStateRet.m_errMsg.c_str());
 				errmsg = CSimpleStringA::Format("updateState is fail, userCode = %s, errmsg = %s",updateStateRet.m_userCode.c_str(), updateStateRet.m_errMsg.c_str());
 				return false;
@@ -534,7 +537,8 @@ namespace Task
 			updateFailReq.m_reqStr = jsonReq;//请求参数
 			updateFailReq.m_url = m_fsm->m_centerUrl.addUploadFailUrl;//访问地址
 
-			if(!client->Post(updateFailReq, updateFailRet)){
+			PROCESS_LINK_CONTEXT("LR0402104UpdateFail")
+			if(!client->Post(updateFailReq, updateFailRet, &nextLink)){
 				DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("addUploadFail is fail,userCode = %s",updateFailRet.m_userCode.c_str());
 				return false;
 			}
@@ -1272,7 +1276,8 @@ bool UploadFSM::queryPlan()
 	//planReq.m_printDbg = true;
 	planReq.m_url = m_centerUrl.queryPlanUrl.c_str();
 
-	if(!client->Post(planReq, planRet)){
+	PROCESS_LINK_CONTEXT("LR0402104QueryPlan")
+	if(!client->Post(planReq, planRet, &nextLink)){
 		LogWarn(Severity_Middle, Error_Unexpect, LOG_WARN_UPLOAD_QUERY_PLAN_ERROR, CSimpleStringA::Format("queryPlan http req fail,url is %s, err=%s",m_centerUrl.queryPlanUrl.c_str(),planRet.m_errMsg.c_str()).GetData());
 		client->Destory();
 		return false;//http错误,走旧模式

+ 2 - 1
Other/libRestfulFunc/RestfulFunc.h

@@ -25,6 +25,7 @@
 #include <map>
 #include <vector>
 #include <sstream>
+#include "httpTrace_define.hpp"
 
 /*
 * > 0 : 网站返回的错误码,比如 200,404 等
@@ -291,7 +292,7 @@ public:
     static RestfulClient& getInstance(); // Singleton
     ~RestfulClient();
 
-    void Do(const HttpClientRequestConfig* const pRequestConfig, HttpClientResponseResult* pResponse) const;
+    void Do(const HttpClientRequestConfig* const pRequestConfig, HttpClientResponseResult* pResponse, HttpClientTraceLink* pTrace) const;
 
 private:
     RestfulClient();

+ 15 - 1
Other/libRestfulFunc/RestfulFuncImpl.cpp

@@ -159,7 +159,7 @@ namespace
     }
 }
 
-void RestfulClient::Do(const HttpClientRequestConfig* const pRequestConfig, HttpClientResponseResult* pResponse) const
+void RestfulClient::Do(const HttpClientRequestConfig* const pRequestConfig, HttpClientResponseResult* pResponse, HttpClientTraceLink* pTrace) const
 {
 	http_client_config config;
 	config.set_validate_certificates(pRequestConfig->NeedValidCert());
@@ -189,6 +189,20 @@ void RestfulClient::Do(const HttpClientRequestConfig* const pRequestConfig, Http
 		request.headers().add(STRW("terminalno"), STRW(terminalno));
 	}
 
+	if (pTrace != NULL
+		&& strlen(pTrace->X_B3_BusinessId) > 0
+		&& strlen(pTrace->X_B3_TraceId) > 0
+		&& strlen(pTrace->X_B3_SpanId) > 0
+		&& strlen(pTrace->X_B3_ParentSpanId) > 0
+		&& strlen(pTrace->X_B3_Timestamp) > 0)
+	{
+		request.headers().add(STRW("X_B3_BusinessId"), STRW(pTrace->X_B3_BusinessId));
+		request.headers().add(STRW("X_B3_TraceId"), STRW(pTrace->X_B3_BusinessId));
+		request.headers().add(STRW("X_B3_SpanId"), STRW(pTrace->X_B3_BusinessId));
+		request.headers().add(STRW("X_B3_ParentSpanId"), STRW(pTrace->X_B3_BusinessId));
+		request.headers().add(STRW("X_B3_Timestamp"), STRW(pTrace->X_B3_BusinessId));
+	}
+
 	if (pRequestConfig->GetRequestType() != HttpRequestMethod::GET) {
 		request.set_body(STRW(pRequestConfig->GetBodyContent()), STRW(pRequestConfig->GetContentType()));
 	}

+ 4 - 4
Other/libRestfulFunc/test/testNormlReqAns.cpp

@@ -8,7 +8,7 @@ TEST_CASE("test api manage", "[restful]")
     HttpClientResponseResult result;
     config.SetChildUri("/api/manage/regist/7555980103");
     RestfulClient client = RestfulClient::getInstance();
-    client.Do(&config, &result);
+    client.Do(&config, &result,NULL);
     std::cout << result.content << std::endl;
     REQUIRE(!result.content.empty());
 }
@@ -20,7 +20,7 @@ TEST_CASE("test  api stage get api", "[restful]")
     config.SetChildUri("/api/stage");
     config.AppendQuery("terminalNo", "7555980001");
     RestfulClient client = RestfulClient::getInstance();
-    client.Do(&config, &result);
+    client.Do(&config, &result, NULL);
     std::cout << result.content << std::endl;
     REQUIRE(!result.content.empty());
 }
@@ -33,7 +33,7 @@ TEST_CASE("test  api stage post api", "[restful]")
     config.SetJsonBody("{\"terminalNo\":\"7555980001\", \"errEntityList\":\"566666\"}");
     RestfulClient client = RestfulClient::getInstance();
     HttpClientResponseResult result;
-    client.Do(&config, &result);
+    client.Do(&config, &result, NULL);
     std::cout << result.content << std::endl;
     REQUIRE(!result.content.empty());
 }
@@ -47,7 +47,7 @@ TEST_CASE("test  api stage upload api", "[restful]")
     RestfulClient client = RestfulClient::getInstance();
     HttpClientResponseResult result;
     config.PreDo();
-    client.Do(&config, &result);
+    client.Do(&config, &result, NULL);
     std::cout << result.content << std::endl;
     REQUIRE(!result.content.empty());
 }

+ 221 - 17
Other/libpublicFun/exLog/skyeyeLog.cpp

@@ -32,6 +32,7 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #endif
+#include <SpBase.h>
 
 #define MAX_LOG_LEN 1900
 void skyeye_GetToken(char* channelId, char* token, char* terminalno, char* reserve1);
@@ -111,6 +112,7 @@ int GetLocalIP(char* ip_str)
 }
 
 
+
 std::string get_format_uuid()
 {
 	char strbuffer[64] = "";
@@ -162,6 +164,30 @@ public:
 	std::pair<std::string ,std::string> getToken()
 	{
 		auto execute_refreshToken = [this] {
+			std::string srcBusId = "LR0402000GetToken";
+			std::string srcTraceId = uuid4_generate(32);
+			std::string srcSpanId = uuid4_generate(16);
+			std::string srcParentSpanId = "0";
+			std::string srcTimestamp = std::to_string(std::chrono::system_clock::now().time_since_epoch().count());
+
+			HttpClientTraceLink headLink;
+			memset(&headLink, 0, sizeof(headLink));
+			strncpy(headLink.X_B3_BusinessId, srcBusId.c_str(), 32);
+			strncpy(headLink.X_B3_TraceId, srcTraceId.c_str(), 32);
+			strncpy(headLink.X_B3_SpanId, srcSpanId.c_str(), 16);
+			strncpy(headLink.X_B3_ParentSpanId, srcParentSpanId.c_str(), 16);
+			strncpy(headLink.X_B3_Timestamp, srcTimestamp.c_str(), 16);
+
+			beidou_logger::getDefaultLogger(headLink, "guardian_getToken")();
+			HttpClientTraceLink nextLink;
+			memset(&nextLink, 0, sizeof(nextLink));
+			std::string nextSpanId = uuid4_generate(16);
+			strncpy(nextLink.X_B3_BusinessId, srcBusId.c_str(), 32);
+			strncpy(nextLink.X_B3_TraceId, srcTraceId.c_str(), 32);
+			strncpy(nextLink.X_B3_SpanId, nextSpanId.c_str(), 16);
+			strncpy(nextLink.X_B3_ParentSpanId, srcSpanId.c_str(), 16);
+			strncpy(nextLink.X_B3_Timestamp, srcTimestamp.c_str(), 16);
+
 			HttpClientRequestConfig config(HttpRequestMethod::POST, endpoint, NULL);
 			HttpClientResponseResult result;
 
@@ -181,7 +207,7 @@ public:
 			config.SetJsonBody(root_str);
 
 			RestfulClient client = RestfulClient::getInstance();
-			client.Do(&config, &result);
+			client.Do(&config, &result, &nextLink);
 			if (result.ResponseOK()) {
 				//解析返回字符串
 				Json::Reader reader;
@@ -307,8 +333,42 @@ class skyeye_sender {
 private:
 	std::mutex m_mtx;
 	std::list<Link_private> m_msgArr;
+	std::list<Beidou_private> m_beidouMsgArr;
 	int m_TimeSn;
 	std::chrono::system_clock::time_point m_beginTime;
+	std::string convertBeidouPrivateToStr(const Beidou_private& cur)
+	{
+		static char local_ip_str[64] = "0.0.0.0";
+		static long ipInit = 0;
+		//get ip every 1000 times
+		if (ipInit % 1000 == 0)
+			GetLocalIP(local_ip_str);
+		ipInit++;
+
+		const char* t_header = "[[tracing]]";
+		Json::Value root;
+		root["businessId"] = cur.BussID;
+		root["traceId"] = cur.TraceID;
+		root["spanId"] = cur.SpanId;
+		root["parentSpanId"] = cur.ParentSpanId;
+		root["timestamp"] = cur.t_timeStamp;
+		root["deployUnitId"] = skyeye_logger::getDefaultLogger().m_constParam.m_deployUnitId;
+		root["serviceUnitId"] = skyeye_logger::getDefaultLogger().m_constParam.m_serviceUnitId;
+		root["host"] = cur.Host;
+		root["api"] = cur.Api;
+		root["responseTime"] = cur.ResponseTime;
+		root["returnCode"] = cur.ReturnCode;
+
+		root["callStack"] = Json::arrayValue;
+		root["tags"]["TerminalNo"] = skyeye_logger::getDefaultLogger().m_constParam.m_terminalNo;
+		root["dbStack"] = Json::arrayValue; // 空数组
+
+		Json::FastWriter writer;
+		std::string dst = t_header + writer.write(root) + t_header;
+		return dst;
+	}
+
+
 	std::string convertLinkPrivateToStr(const Link_private& cur)
 	{
 		static char local_ip_str[64] = "0.0.0.0";
@@ -368,20 +428,99 @@ public:
 	}
 	void LogToSender(Link_private* msg)
 	{
-		
 		m_mtx.lock();
 		m_msgArr.push_back(*msg);
 		m_mtx.unlock();
-		
 	}
-	void InitSender(std::string t_endpoint, std::string t_topic)
+	void LogToBeidouSender(Beidou_private* msg)
+	{
+		m_mtx.lock();
+		m_beidouMsgArr.push_back(*msg);
+		m_mtx.unlock();
+	}
+
+
+	void InitSender(std::string t_endpoint, std::string t_topic, std::string t_beidou_topic)
 	{
 		
-		auto skyeye_sender = [this](std::string t_endpoint, std::string t_topic) {
-			while (true)
-			{
-				if (m_msgArr.empty())
-					std::this_thread::sleep_for(std::chrono::seconds(1));//every 1 seconds
+		auto skyeye_sender = [this](std::string t_endpoint, std::string t_topic, std::string t_beidou_topic) {
+			auto beidou_send = [&]{
+				std::vector<Beidou_private> sendArr;
+				m_mtx.lock();
+				//max send 12 logs
+				for (int i = 0; i < 12; i++)
+				{
+					if (m_beidouMsgArr.size() == 0)
+						break;
+					sendArr.emplace_back(m_beidouMsgArr.front());
+					m_beidouMsgArr.pop_front();
+				}
+				m_mtx.unlock();
+
+				if (sendArr.size() == 0)
+					return; //no need to send
+
+				//generate send str
+				Json::Value root;
+				Json::Value arraylist;//消息列表
+				Json::FastWriter fw;//写入对象
+				for (int i = 0; i < sendArr.size(); i++)
+					arraylist[i] = convertBeidouPrivateToStr(sendArr[i]);
+				root["message_list"] = arraylist;
+				root["topic"] = t_beidou_topic;
+				auto sendStr = fw.write(root);
+				//send
+				HttpClientResponseResult result;
+				HttpClientRequestConfig config(HttpRequestMethod::POST, t_endpoint, skyeye_GetToken);
+				config.SetTimeout(60);
+
+				config.SetJsonBody(sendStr.c_str());
+
+				RestfulClient client = RestfulClient::getInstance();
+				config.PreDo();
+				client.Do(&config, &result, NULL);
+				if (result.ResponseOK()) {
+					struct CommResponse
+					{
+						bool success;
+						std::string errorCode;
+						std::string returnCode;
+						std::string errorMsg;
+						std::string message;
+
+						JSONCONVERT2OBJECT_MEMEBER_REGISTER(success, errorCode, returnCode, errorMsg, message)
+							JSONCONVERT2OBJECT_MEMEBER_RENAME_REGISTER("success", "code", "return_code", "error_msg", "message")
+					} responseIns;
+
+					Json::Value rawRoot;
+					if (GetJsonRootObject(rawRoot, result.content) && Json2Object(responseIns, rawRoot)) {
+						if (!responseIns.success)
+						{
+							if (responseIns.errorCode.find("RTI1002") != -1)
+							{
+								m_mtx.lock();
+
+								for (auto it : sendArr)
+									m_beidouMsgArr.emplace_back(it);
+								m_mtx.unlock();
+								std::this_thread::sleep_for(std::chrono::seconds(30));//upload logs failed
+							}
+						}
+					}
+				}
+				else
+				{
+					m_mtx.lock();
+
+					for (auto it : sendArr)
+						m_beidouMsgArr.emplace_back(it);
+					m_mtx.unlock();
+				}
+			};
+
+
+
+			auto skyeye_send = [&]{
 				std::vector<Link_private> sendArr;
 				m_mtx.lock();
 				//max send 12 logs
@@ -389,23 +528,20 @@ public:
 				{
 					if (m_msgArr.size() == 0)
 						break;
-
 					sendArr.emplace_back(m_msgArr.front());
 					m_msgArr.pop_front();
 				}
 				m_mtx.unlock();
 
 				if (sendArr.size() == 0)
-					continue; //no need to send
+					return; //no need to send
 
 				//generate send str
 				Json::Value root;
 				Json::Value arraylist;//消息列表
 				Json::FastWriter fw;//写入对象
 				for (int i = 0; i < sendArr.size(); i++)
-				{
 					arraylist[i] = convertLinkPrivateToStr(sendArr[i]);
-				}
 				root["message_list"] = arraylist;
 				root["topic"] = t_topic;
 				auto sendStr = fw.write(root);
@@ -420,7 +556,7 @@ public:
 
 				RestfulClient client = RestfulClient::getInstance();
 				config.PreDo();
-				client.Do(&config, &result);
+				client.Do(&config, &result, NULL);
 				if (result.ResponseOK()) {
 					struct CommResponse
 					{
@@ -458,11 +594,25 @@ public:
 						m_msgArr.emplace_back(it);
 					m_mtx.unlock();
 				}
+			};
+
+
+			while (true)
+			{
+				if (m_msgArr.empty() && m_beidouMsgArr.empty())
+				{
+					std::this_thread::sleep_for(std::chrono::seconds(1));//every 1 seconds
+					continue;
+				}
+				if (!m_msgArr.empty())
+					skyeye_send();
+				if (!m_beidouMsgArr.empty())
+					beidou_send();
 			}
 			
 		};
 		
-		std::thread(skyeye_sender, t_endpoint, t_topic).detach();
+		std::thread(skyeye_sender, t_endpoint, t_topic, t_beidou_topic).detach();
 	}
 
 	skyeye_sender()
@@ -649,7 +799,8 @@ void CreateDefaultLogger(std::string logEndpoint, std::string logTopic,std::stri
 {
 	skyeye_logger::getDefaultLogger().m_constParam = constParam;
 	TokenManager::getInstance().InitTokenManager(30, tokenEndpoint, channelId, tokenSecret, constParam.m_terminalNo, constParam.m_version);
-	skyeye_sender::getInstance().InitSender(logEndpoint, logTopic);
+	std::string beidouTopic = SpDefine::topicBeidou;
+	skyeye_sender::getInstance().InitSender(logEndpoint, logTopic, beidouTopic);
 }
 
 void CreateDefaultLogger(std::string terminalno, std::string version, std::string entityName, std::string itemId)
@@ -669,7 +820,9 @@ void CreateDefaultLogger(std::string terminalno, std::string version, std::strin
 	//skyeye_sender::getInstance();
 	std::string endpoint = SpDefine::endpoint_env;
 	std::string topic = SpDefine::topicSys;
-	skyeye_sender::getInstance().InitSender(endpoint, topic);
+	std::string beidouTopic = SpDefine::topicBeidou;
+
+	skyeye_sender::getInstance().InitSender(endpoint, topic, beidouTopic);
 
 }
 
@@ -677,3 +830,54 @@ skyeye_logger& GetDefaultLogger()
 {
 	return skyeye_logger::getDefaultLogger();
 }
+
+
+beidou_logger& beidou_logger::getDefaultLogger(const HttpClientTraceLink& t_context, const std::string& t_Api)
+{
+	// TODO: 在此处插入 return 语句
+	static beidou_logger cur;
+	if (cur.m_msg == nullptr)
+		cur.m_msg = new Beidou_private(t_context, t_Api);
+	else
+	{
+		delete cur.m_msg;
+		cur.m_msg = new Beidou_private(t_context, t_Api);
+	}
+	return cur;
+}
+
+beidou_logger& beidou_logger::setHost(std::string t_host) {
+    m_msg->Host = t_host;
+    return *this;
+}
+
+beidou_logger& beidou_logger::setReturnCode(std::string t_ReturnCode) {
+    m_msg->ReturnCode = t_ReturnCode;
+    return *this;
+}
+
+beidou_logger& beidou_logger::setResponseTime(std::string t_ResponseTime) {
+    m_msg->ResponseTime = t_ResponseTime;
+    return *this;
+}
+
+
+
+beidou_logger& beidou_logger::set_deployUnitId(std::string t_deployUnitId) {
+    m_msg->deployUnitId = t_deployUnitId;
+    return *this;
+}
+beidou_logger& beidou_logger::set_serviceUnitId(std::string t_serviceUnitId) {
+    m_msg->serviceUnitId = t_serviceUnitId;
+    return *this;
+}
+
+void beidou_logger::operator () () {
+	if(m_msg)
+	{
+		skyeye_sender::getInstance().LogToBeidouSender(m_msg);
+
+		delete m_msg;
+		m_msg = nullptr;
+	}	
+}

+ 51 - 0
Other/libpublicFun/exLog/skyeyeLog.h

@@ -1,4 +1,5 @@
 #include <log_define.h>
+#include <httpTrace_define.hpp>
 #include <string>
 #include "../publicExport.h"
 
@@ -16,6 +17,38 @@ public:
 	std::string m_version;
 };
 
+class Beidou_private {
+public:
+    std::string BussID;
+    std::string TraceID; // 链路追踪标记,用于标记一笔业务
+    std::string ParentSpanId; // 父节点标记
+    std::string SpanId; // 当前节点标记
+    std::string Host;
+    std::string Api;
+    std::string ReturnCode;
+    std::string ResponseTime;
+    std::string deployUnitId;
+    std::string serviceUnitId;
+	std::string t_timeStamp;
+    void* logProducer;
+
+    Beidou_private(const HttpClientTraceLink& t_context, const std::string& t_Api)
+        : logProducer(nullptr) // 使用 nullptr 替代 NULL
+    {
+        BussID = t_context.X_B3_BusinessId;
+        TraceID = t_context.X_B3_TraceId;
+        ParentSpanId = t_context.X_B3_ParentSpanId;
+        SpanId = t_context.X_B3_SpanId;
+		t_timeStamp = t_context.X_B3_Timestamp;
+        Api = t_Api;
+        ReturnCode = "SUC0000";
+        ResponseTime = "0";
+        Host = "vtmtlog.paas.cmbchina.cn:8080";
+        deployUnitId = "";
+        serviceUnitId = "";
+    }
+};
+
 class Link_private {
 public:
 	LOG_LEVEL_E Level;
@@ -123,6 +156,24 @@ private:
 	const skyeye_logger& operator=(const skyeye_logger&) = delete;
 };
 
+class PUBLIC_API beidou_logger {
+public:
+	static beidou_logger& getDefaultLogger(const HttpClientTraceLink& t_context, const std::string& t_Api);
+
+	beidou_logger& setHost(std::string t_host);//请求链接地址
+	beidou_logger& setReturnCode(std::string t_returncode);
+	beidou_logger& setResponseTime(std::string t_responseTime);
+	beidou_logger& set_deployUnitId(std::string t_deployUnitId);
+	beidou_logger& set_serviceUnitId(std::string t_serviceUnitId);
+	beidou_logger& withLogProducer(void* t_logProducer);
+	void operator () ();
+private:
+	Beidou_private* m_msg;
+private:
+	beidou_logger() {};
+	beidou_logger(const beidou_logger&) = delete;
+};
+
 //CreateDefaultLogger with all params
 PUBLIC_API void CreateDefaultLogger(std::string logEndpoint, std::string logTopic, std::string tokenEndpoint, std::string channelId, std::string tokenSecret, Link_const constParam);
 //CreateDefaultLogger with neccessary params, other params use default values.

+ 110 - 95
addin/res/VTMModifyHeaders/background.js

@@ -13,7 +13,7 @@
 let config;
 let started = 'on';
 let debug_mode = true;
-const isChrome = false;
+const isChrome = true;
 let config_read_type = 'websocket';//local,file,websocket,http
 const wsUrl = 'ws://127.0.0.1:9002?name=vtm_modify_header';
 let socket = null;
@@ -25,75 +25,73 @@ addListener();
 chrome.runtime.onMessage.addListener(notify);
 
 function connectWebSocket(callback_function) {
-    let socket = null; // 初始化 socket 变量
-    let timeoutId = setTimeout(() => {
-        socket.close();
-        callback_function(null); // 超时回调 null
-    }, 3000); // 5秒 = 5000 毫秒
-    let connectionOpened = false; // 标记连接是否已经打开
-
-    try {
-        socket = new WebSocket(wsUrl);
-    } catch (error) {
-        log('WebSocket connection creation error: ' + error);
-        callback_function(null); // 连接创建失败,回调 null
-        return;
-    }
-
-
-    socket.onmessage = function (event) {
-        log('Received message:' + event.data);
-        clearTimeout(timeoutId); // 清除定时器
-        if (socket && socket.readyState === WebSocket.OPEN) { // 检查连接状态
-            socket.close();
-        }
-        callback_function(event.data);
-        return;
-    };
-
-    socket.onopen = function () {
-        log('WebSocket connection established');
-        connectionOpened = true; // 设置连接已打开标志
-        // 发送配置请求
-        let requestData = '{"messageType":131073}';
-        log('Send message:' + requestData);
-        socket.send(requestData);
-    };
+  let socket = null; // 初始化 socket 变量
+  let timeoutId = setTimeout(() => {
+    socket.close();
+    callback_function(null); // 超时回调 null
+  }, 3000); // 5秒 = 5000 毫秒
+  let connectionOpened = false; // 标记连接是否已经打开
+
+  try {
+    socket = new WebSocket(wsUrl);
+  } catch (error) {
+    log('WebSocket connection creation error: ' + error);
+    callback_function(null); // 连接创建失败,回调 null
+    return;
+  }
 
-    socket.onerror = function (error) {
-        log('WebSocket connection error:' + error);
-        clearTimeout(timeoutId); // 清除定时器
-        if (socket && socket.readyState === WebSocket.OPEN) { // 检查连接状态
-            socket.close();
-        }
-        callback_function(null); // 错误回调 null
-    };
 
-    socket.onclose = function (event) {
-        log('WebSocket connection closed:' + event.reason);
-        clearTimeout(timeoutId); // 清除定时器
-        connectionOpened = false; // 重置连接已打开标志
-        if (event.reason !== 'Connection timed out') { // 如果不是超时关闭
-            callback_function(null); // 连接意外关闭,回调 null
-        }
-    };
+  socket.onmessage = function (event) {
+    log('Received message:' + event.data);
+    clearTimeout(timeoutId); // 清除定时器
+    if (socket && socket.readyState === WebSocket.OPEN) { // 检查连接状态
+      socket.close();
+    }
+    callback_function(event.data);
+    return;
+  };
+
+  socket.onopen = function () {
+    log('WebSocket connection established');
+    connectionOpened = true; // 设置连接已打开标志
+    // 发送配置请求
+    let requestData = '{"messageType":131073}';
+    log('Send message:' + requestData);
+    socket.send(requestData);
+  };
+
+  socket.onerror = function (error) {
+    log('WebSocket connection error:' + error);
+    clearTimeout(timeoutId); // 清除定时器
+    if (socket && socket.readyState === WebSocket.OPEN) { // 检查连接状态
+      socket.close();
+    }
+    callback_function(null); // 错误回调 null
+  };
+
+  socket.onclose = function (event) {
+    log('WebSocket connection closed:' + event.reason);
+    clearTimeout(timeoutId); // 清除定时器
+    connectionOpened = false; // 重置连接已打开标志
+    if (event.reason !== 'Connection timed out') { // 如果不是超时关闭
+      callback_function(null); // 连接意外关闭,回调 null
+    }
+  };
 }
 
 
 function loadConfigurationFromLocalStorage() {
-  if(config_read_type == 'local')
-  {
+  if (config_read_type == 'local') {
     let headers = [];
     headers.push({ url_contains: "", action: "add", header_name: "terminalno", header_value: "7555980178", comment: "test", apply_on: "req", status: "on" });
-    config = { format_version: "1.1", target_page: "", headers: headers, debug_mode: true, use_url_contains: false };
+    config = { format_version: "1.1", target_page: "", headers: headers, debug_mode: true, use_url_excepts: false };
     log("current new config" + JSON.stringify(config));
 
 
     storeInBrowserStorage({ config: JSON.stringify(config) });
     started = 'on';
   }
-  else if(config_read_type == 'file')
-  {
+  else if (config_read_type == 'file') {
     log('loadConfigurationFromLocalStorage');
     const filePath = 'file:///D:/Run/runinfo/runcfg/config.json'; // 指定本地文件路径
     fetch(filePath)
@@ -108,16 +106,15 @@ function loadConfigurationFromLocalStorage() {
         console.error('Error reading file:', error);
       });
   }
-  else if(config_read_type == 'websocket')
-  {
-      connectWebSocket(function (dataStr) {
-          if (dataStr == null)
-              return;
-          let data = JSON.parse(dataStr);
-          log("current new config:" + JSON.stringify(data));
-          config = data
-          storeInBrowserStorage({ config: JSON.stringify(data) });
-          started = 'on';
+  else if (config_read_type == 'websocket') {
+    connectWebSocket(function (dataStr) {
+      if (dataStr == null)
+        return;
+      let data = JSON.parse(dataStr);
+      log("current new config:" + JSON.stringify(data));
+      config = data
+      storeInBrowserStorage({ config: JSON.stringify(data) });
+      started = 'on';
     });
   }
 }
@@ -135,23 +132,23 @@ function storeInBrowserStorage(item, callback_function) {
 
 
 function cookie_keyvalues_set(original_cookies, key, value) {
-    let new_element = " " + key + "=" + value; // not used if value is undefined. 
-    let cookies_ar = original_cookies.split(";").filter(e => e.trim().length > 0);
-    let selected_cookie_index = cookies_ar.findIndex(kv => kv.trim().startsWith(key+"="));
-    if ((selected_cookie_index == -1) && (value != undefined)) cookies_ar.push(new_element);
-    else {
-        if (value === undefined)
-            cookies_ar.splice(selected_cookie_index, 1);
-        else
-            cookies_ar.splice(selected_cookie_index, 1, new_element);
-    }
-    return cookies_ar.join(";");
+  let new_element = " " + key + "=" + value; // not used if value is undefined. 
+  let cookies_ar = original_cookies.split(";").filter(e => e.trim().length > 0);
+  let selected_cookie_index = cookies_ar.findIndex(kv => kv.trim().startsWith(key + "="));
+  if ((selected_cookie_index == -1) && (value != undefined)) cookies_ar.push(new_element);
+  else {
+    if (value === undefined)
+      cookies_ar.splice(selected_cookie_index, 1);
+    else
+      cookies_ar.splice(selected_cookie_index, 1, new_element);
+  }
+  return cookies_ar.join(";");
 }
 
 function set_cookie_modify_cookie_value(original_set_cookie_header_content, key, new_value) {
-    let trimmed = original_set_cookie_header_content.trimStart();
-    let original_attributes = trimmed.indexOf(";") === -1 ? "" : trimmed.substring(trimmed.indexOf(";"))
-    return key + "=" + new_value + original_attributes;
+  let trimmed = original_set_cookie_header_content.trimStart();
+  let original_attributes = trimmed.indexOf(";") === -1 ? "" : trimmed.substring(trimmed.indexOf(";"))
+  return key + "=" + new_value + original_attributes;
 }
 
 
@@ -169,16 +166,31 @@ function log(message) {
 *
 */
 function rewriteRequestHeader(e) {
-  if (config.debug_mode) log("Start modify request headers for url " + e.url);
+  if (config.debug_mode) 
+    log("Start modify request headers for url " + e.url + "use_url_excepts:" + config.use_url_excepts)
   for (let to_modify of config.headers) {
-    if ((to_modify.status === "on") && (to_modify.apply_on === "req") && (!config.use_url_contains || (config.use_url_contains && e.url.includes(to_modify.url_contains.trim())))) {
+    if (config.debug_mode)
+      log("to_modify.url_contains:" + to_modify.url_contains + " e.url:" + e.url + ", result:" + !e.url.includes(to_modify.url_contains.trim()));
+
+    const shouldApplyModification = (to_modify, config, e) => {
+      const isStatusOn = to_modify.status === "on";
+      const isApplyOnReq = to_modify.apply_on === "req";
+      const isUrlExcepted = config.use_url_excepts 
+        ? to_modify.url_contains.length > 0 && e.url.includes(to_modify.url_contains.trim())
+        : false;
+      
+      return isStatusOn && isApplyOnReq && !isUrlExcepted;
+    };
+
+    if (shouldApplyModification(to_modify, config, e)) {
       if (to_modify.action === "add") {
         let new_header = { "name": to_modify.header_name, "value": to_modify.header_value };
         e.requestHeaders.push(new_header);
         if (config.debug_mode) log("Add request header : name=" + to_modify.header_name +
-          ",value=" + to_modify.header_value + " for url " + e.url);
+          ",value=" + to_modify.header_value + " for url " + e.url + " url_contains " + to_modify.url_contains);
       }
       else if (to_modify.action === "modify") {
+        log("modify request header");
         for (let header of e.requestHeaders) {
           if (header.name.toLowerCase() === to_modify.header_name.toLowerCase()) {
             if (config.debug_mode) log("Modify request header :  name= " + to_modify.header_name +
@@ -189,6 +201,7 @@ function rewriteRequestHeader(e) {
         }
       }
       else if (to_modify.action === "delete") {
+        log("Delete request header");
         let index = -1;
         for (let i = 0; i < e.requestHeaders.length; i++) {
           if (e.requestHeaders[i].name.toLowerCase() === to_modify.header_name.toLowerCase()) index = i;
@@ -200,10 +213,11 @@ function rewriteRequestHeader(e) {
         }
       }
       else if (to_modify.action === "cookie_add_or_modify") {
+        log("cookie_add_or_modify.req");
         let header_cookie = e.requestHeaders.find(header => header.name.toLowerCase() === "cookie");
         let new_cookie = cookie_keyvalues_set(header_cookie === undefined ? "" : header_cookie.value, to_modify.header_name, to_modify.header_value);
         if (header_cookie === undefined) {
-          e.requestHeaders.push({"name": "Cookie", "value": new_cookie});
+          e.requestHeaders.push({ "name": "Cookie", "value": new_cookie });
           if (config.debug_mode) log("cookie_add_or_modify.req new_header : name=Cookie,value=" + new_cookie + " for url " + e.url);
         }
         else {
@@ -212,6 +226,7 @@ function rewriteRequestHeader(e) {
         }
       }
       else if (to_modify.action === "cookie_delete") {
+        log("cookie_delete.req");
         let header_cookie = e.requestHeaders.find(header => header.name.toLowerCase() === "cookie");
         let new_cookie = cookie_keyvalues_set(header_cookie === undefined ? "" : header_cookie.value, to_modify.header_name, undefined);
         if (header_cookie === undefined) {
@@ -234,9 +249,9 @@ function rewriteRequestHeader(e) {
 *
 */
 function rewriteResponseHeader(e) {
-  if (config.debug_mode) log("Start modify response headers for url " + e.url);
+  //if (config.debug_mode) log("Start modify response headers for url " + e.url);
   for (let to_modify of config.headers) {
-    if ((to_modify.status === "on") && (to_modify.apply_on === "res") && (!config.use_url_contains || (config.use_url_contains && e.url.includes(to_modify.url_contains.trim())))) {
+    if ((to_modify.status === "on") && (to_modify.apply_on === "res") && (!config.use_url_excepts || (config.use_url_excepts && e.url.includes(to_modify.url_contains.trim())))) {
       if (to_modify.action === "add") {
         let new_header = { "name": to_modify.header_name, "value": to_modify.header_value };
         e.responseHeaders.push(new_header);
@@ -264,14 +279,14 @@ function rewriteResponseHeader(e) {
         }
       }
       else if (to_modify.action === "cookie_add_or_modify") {
-        let header_cookie = e.responseHeaders.find(header => 
-            header.name.toLowerCase() === "set-cookie" && 
-            header.value.toLowerCase().trim().startsWith(to_modify.header_name.toLowerCase()+"=")
+        let header_cookie = e.responseHeaders.find(header =>
+          header.name.toLowerCase() === "set-cookie" &&
+          header.value.toLowerCase().trim().startsWith(to_modify.header_name.toLowerCase() + "=")
         );
         let new_header_value = set_cookie_modify_cookie_value(header_cookie === undefined ? "" : header_cookie.value, to_modify.header_name, to_modify.header_value);
         if (header_cookie === undefined) {
           log("SimpleModifyHeaders.Warning: you're using cookie_add_or_modify in Response. While adding new cookie in response, this plugin only generates `Set-Cookie: cookie-name=cookie-value `, without ANY additional attributes. Add a `Set-Cookie` header if you need them. ");
-          e.responseHeaders.push({"name": "Set-Cookie", "value": new_header_value});
+          e.responseHeaders.push({ "name": "Set-Cookie", "value": new_header_value });
           if (config.debug_mode) log("cookie_add_or_modify.resp new_header : name=Cookie,value=" + new_header_value + " for url " + e.url);
         }
         else {
@@ -280,9 +295,9 @@ function rewriteResponseHeader(e) {
         }
       }
       else if (to_modify.action === "cookie_delete") {
-        let index = e.responseHeaders.findIndex(header => 
-            header.name.toLowerCase() === "set-cookie" && 
-            header.value.toLowerCase().trim().startsWith(to_modify.header_name.toLowerCase()+"=")
+        let index = e.responseHeaders.findIndex(header =>
+          header.name.toLowerCase() === "set-cookie" &&
+          header.value.toLowerCase().trim().startsWith(to_modify.header_name.toLowerCase() + "=")
         );
         if (index === -1) {
           if (config.debug_mode) log("cookie_delete.resp: no matching set-cookie header. doing nothing for url " + e.url);
@@ -294,7 +309,7 @@ function rewriteResponseHeader(e) {
       }
     }
   }
-  if (config.debug_mode) log("End modify response headers for url " + e.url);
+  //if (config.debug_mode) log("End modify response headers for url " + e.url);
   return { responseHeaders: e.responseHeaders };
 }
 
@@ -356,7 +371,7 @@ function addListener() {
       { urls: target.split(";") },
       ["blocking", "responseHeaders"]);
   }
-
+  
 }