浏览代码

HPCC-16840 Do not log TxSummary if both user and request are empty

Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
wangkx 8 年之前
父节点
当前提交
4688a11415
共有 2 个文件被更改,包括 21 次插入5 次删除
  1. 20 4
      esp/platform/espcontext.cpp
  2. 1 1
      esp/platform/txsummary.cpp

+ 20 - 4
esp/platform/espcontext.cpp

@@ -586,12 +586,28 @@ void CEspContext::updateTraceSummaryHeader()
     if (m_txSummary)
     if (m_txSummary)
     {
     {
         m_txSummary->set("activeReqs", m_active);
         m_txSummary->set("activeReqs", m_active);
-        m_txSummary->set("user", VStringBuffer("%s%s%s", (queryUserId() ? queryUserId() : ""), (m_peer.length() ? "@" : ""), m_peer.str()).str());
+        VStringBuffer user("%s%s%s", (queryUserId() ? queryUserId() : ""), (m_peer.length() ? "@" : ""), m_peer.str());
+        if (!user.isEmpty())
+            m_txSummary->set("user", user.str());
 
 
-        VStringBuffer reqSummury("%s %s.%s", httpMethod.get(), m_servName.str(), servMethod.get());
+        VStringBuffer reqSummary("%s", httpMethod.isEmpty() ? "" : httpMethod.get());
+        if (!m_servName.isEmpty() || !servMethod.isEmpty())
+        {
+            if (!reqSummary.isEmpty())
+                reqSummary.append(" ");
+            if (!m_servName.isEmpty())
+                reqSummary.append(m_servName.str());
+            if (!servMethod.isEmpty())
+                reqSummary.append(".").append(servMethod.str());
+        }
         if (m_clientVer > 0)
         if (m_clientVer > 0)
-            reqSummury.append(" v").append(m_clientVer);
-        m_txSummary->set("req", reqSummury.str());
+        {
+            if (!reqSummary.isEmpty())
+                reqSummary.append(" ");
+            reqSummary.append("v").append(m_clientVer);
+        }
+        if (!reqSummary.isEmpty())
+            m_txSummary->set("req", reqSummary.str());
 
 
         if (m_hasException)
         if (m_hasException)
             m_txSummary->set(VStringBuffer("exception@%ums", m_exceptionTime), m_exceptionCode);
             m_txSummary->set(VStringBuffer("exception@%ums", m_exceptionTime), m_exceptionCode);

+ 1 - 1
esp/platform/txsummary.cpp

@@ -143,7 +143,7 @@ void CTxSummary::serialize(StringBuffer& buffer) const
 
 
 void CTxSummary::log()
 void CTxSummary::log()
 {
 {
-    if (size())
+    if (__contains("user") || __contains("req"))
     {
     {
         StringBuffer summary;
         StringBuffer summary;
         serialize(summary);
         serialize(summary);