From 23f2e61ac1d69303c216c101e97c1a14b812f6a6 Mon Sep 17 00:00:00 2001 From: wangkx Date: Thu, 7 Sep 2023 08:06:16 -0400 Subject: [PATCH] HPCC-28499 Add roxie stats to WsECL GUI 1. Display checkbox 'Save stats to workunit.' and checkbox 'Get summary stats.' in WsECL GUI. 2. Pass the requests of the 2 checkboxes to WsECL and roxie. 3. Add code to report the summary stats in roxie when the request is sent from WsECL GUI. 4. Display the stats workunit id and the summary stats in WsECL GUI. Revise based on review: 1. Rename the 'save_stats' to '@statsToWorkunit' and rename the 'summary_stats' to 'summaryStats'. 2. Remove the code for converting the 'save_stats' to the '@statsToWorkunit'. The code is not needed. 3. Add the code to pass the '@statsToWorkunit' and '@summaryStats' to the SOAP test form and JSON test form. Signed-off-by: wangkx --- common/wuwebview/wuwebview.cpp | 2 ++ esp/services/common/jsonhelpers.hpp | 6 ++++++ esp/services/ws_ecl/ws_ecl_service.cpp | 6 ++++++ esp/xslt/wsecl3_form.xsl | 8 ++++++++ esp/xslt/wsecl3_result.xslt | 18 ++++++++++++++++++ roxie/ccd/ccdlistener.cpp | 22 ++++++++++++++++++---- 6 files changed, 58 insertions(+), 4 deletions(-) diff --git a/common/wuwebview/wuwebview.cpp b/common/wuwebview/wuwebview.cpp index fb824ccc042..f74f7bdd242 100644 --- a/common/wuwebview/wuwebview.cpp +++ b/common/wuwebview/wuwebview.cpp @@ -80,6 +80,8 @@ class WuExpandedResultBuffer : implements IPTreeNotifyEvent, public CInterface resultChildTags.setValue("Warning", true); resultChildTags.setValue("Alert", true); resultChildTags.setValue("Info", true); + resultChildTags.setValue("StatsWorkUnit", true); + resultChildTags.setValue("SummaryStats", true); } void appendResults(IConstWorkUnit *wu, const char *username, const char *pw) diff --git a/esp/services/common/jsonhelpers.hpp b/esp/services/common/jsonhelpers.hpp index 969dcd40783..9bedec5d2d0 100644 --- a/esp/services/common/jsonhelpers.hpp +++ b/esp/services/common/jsonhelpers.hpp @@ -329,6 +329,12 @@ namespace JsonHelpers bool log = reqTree->getPropBool("@log", false); //not in schema if (log) appendJSONValue(out, "@log", true); + bool statsToWorkunit = reqTree->getPropBool("@statsToWorkunit", false); //not in schema + if (statsToWorkunit) + appendJSONValue(out, "@statsToWorkunit", true); + bool summaryStats = reqTree->getPropBool("@summaryStats", false); //not in schema + if (summaryStats) + appendJSONValue(out, "@summaryStats", true); int tracelevel = reqTree->getPropInt("@traceLevel", -1); if (tracelevel>=0) appendJSONValue(out, "@traceLevel", tracelevel); diff --git a/esp/services/ws_ecl/ws_ecl_service.cpp b/esp/services/ws_ecl/ws_ecl_service.cpp index 12317eb08a6..c2a087e0fe8 100644 --- a/esp/services/ws_ecl/ws_ecl_service.cpp +++ b/esp/services/ws_ecl/ws_ecl_service.cpp @@ -660,6 +660,12 @@ static void buildReqXml(StringArray& parentTypes, IXmlType* type, StringBuffer& bool log = reqTree->getPropBool("@log", false); if (log) appendXMLAttr(out, "log", "true", nullptr, true); + bool statsToWorkunit = reqTree->getPropBool("@statsToWorkunit", false); + if (statsToWorkunit) + appendXMLAttr(out, "statsToWorkunit", "true", nullptr, true); + bool summaryStats = reqTree->getPropBool("@summaryStats", false); + if (summaryStats) + appendXMLAttr(out, "summaryStats", "true", nullptr, true); int tracelevel = reqTree->getPropInt("@traceLevel", -1); if (tracelevel >= 0) out.appendf(" traceLevel=\"%d\"", tracelevel); diff --git a/esp/xslt/wsecl3_form.xsl b/esp/xslt/wsecl3_form.xsl index 5382b3c9291..d2b6a7ff012 100644 --- a/esp/xslt/wsecl3_form.xsl +++ b/esp/xslt/wsecl3_form.xsl @@ -320,6 +320,14 @@ function switchInputForm() + + + +
+ Save stats to workunit.      Get summary stats.
+
+ + diff --git a/esp/xslt/wsecl3_result.xslt b/esp/xslt/wsecl3_result.xslt index 9125c85c977..733fe972474 100644 --- a/esp/xslt/wsecl3_result.xslt +++ b/esp/xslt/wsecl3_result.xslt @@ -77,11 +77,29 @@ + + + + + + + + + SummaryStats: +
+
+
+ + + Stats WorkUnit: +
+
+
Exception
diff --git a/roxie/ccd/ccdlistener.cpp b/roxie/ccd/ccdlistener.cpp index 27b10f94cd6..d659928df9e 100644 --- a/roxie/ccd/ccdlistener.cpp +++ b/roxie/ccd/ccdlistener.cpp @@ -1768,12 +1768,26 @@ class RoxieProtocolMsgSink : implements IHpccNativeProtocolMsgSink, public CInte Owned logwriter = protocol->writeAppendContent(nullptr); msgctx->writeLogXML(*logwriter); } - if (statsWuid.length()) + + bool summaryStats = msg->getPropBool("@summaryStats", false); + if (!statsWuid.isEmpty() || summaryStats) { Owned wuwriter = protocol->writeAppendContent(nullptr); - wuwriter->outputBeginNested("StatsWorkUnit", true); - wuwriter->outputCString(statsWuid.str(), "wuid"); - wuwriter->outputEndNested("StatsWorkUnit"); + if (!statsWuid.isEmpty()) + { + wuwriter->outputBeginNested("StatsWorkUnit", true); + wuwriter->outputCString(statsWuid.str(), "wuid"); + wuwriter->outputEndNested("StatsWorkUnit"); + } + if (summaryStats) + { + //The query completion time needs discussion and is unavailable for now. + VStringBuffer s(" COMPLETE: %s %s memory=%u Mb agentsreply=%u duplicatePackets=%u resentPackets=%u", + target, roxieMsgCtx->uid.str(), memused, agentsReplyLen, agentsDuplicates, agentsResends); + IRoxieContextLogger &logctx = static_cast(*msgctx->queryLogContext()); + logctx.getStats(s).newline(); + wuwriter->outputCString(s.str(), "SummaryStats"); + } } protocol->finalize(idx);