From 156c6cff9d1e3302fe74ad5c482495997dc9a2c4 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Tue, 2 Nov 2021 14:25:30 +0800 Subject: [PATCH] [TD-6452]: taoskeeper add HTTP status codes --- src/dnode/src/dnodeShell.c | 22 ++++++++++++++++------ src/inc/dnode.h | 5 +++-- src/plugins/monitor/src/monMain.c | 5 ++--- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c index b2c898d840..1fd9819d63 100644 --- a/src/dnode/src/dnodeShell.c +++ b/src/dnode/src/dnodeShell.c @@ -242,9 +242,6 @@ SDnodeStatisInfo dnodeGetStatisInfo() { if (dnodeGetRunStatus() == TSDB_RUN_STATUS_RUNING) { #ifdef HTTP_EMBEDDED info.httpReqNum = httpGetReqCount(); - for (int i = 0; i < MAX_HTTP_STATUS_CODE_NUM; ++i) { - info.httpStatusCodeErrs[i] = httpGetStatusCodeCount(i); - } #endif info.queryReqNum = atomic_load_32(&tsQueryReqNum); info.submitReqNum = atomic_load_32(&tsSubmitReqNum); @@ -257,11 +254,24 @@ void dnodeClearStatisInfo() { if (dnodeGetRunStatus() == TSDB_RUN_STATUS_RUNING) { #ifdef HTTP_EMBEDDED httpClearReqCount(); - for (int i = 0; i < MAX_HTTP_STATUS_CODE_NUM; ++i) { - httpClearStatusCodeCount(i); - } #endif atomic_exchange_32(&tsQueryReqNum, 0); atomic_exchange_32(&tsSubmitReqNum, 0); } } + +int32_t dnodeGetHttpStatusInfo(int32_t index) { + int32_t httpStatus = 0; +#ifdef HTTP_EMBEDDED + httpStatus = httpGetStatusCodeCount(index); +#endif + return httpStatus; +} + +void dnodeClearHttpStatusInfo() { +#ifdef HTTP_EMBEDDED + for (int i = 0; i < MAX_HTTP_STATUS_CODE_NUM; ++i) { + httpClearStatusCodeCount(i); + } +#endif +} diff --git a/src/inc/dnode.h b/src/inc/dnode.h index f1b106b11b..80c74de905 100644 --- a/src/inc/dnode.h +++ b/src/inc/dnode.h @@ -28,11 +28,12 @@ typedef struct { int32_t queryReqNum; int32_t submitReqNum; int32_t httpReqNum; - int32_t httpStatusCodeErrs[MAX_HTTP_STATUS_CODE_NUM]; } SDnodeStatisInfo; SDnodeStatisInfo dnodeGetStatisInfo(); -void dnodeClearStatisInfo(); +void dnodeClearStatisInfo(); +int32_t dnodeGetHttpStatusInfo(int32_t index); +void dnodeClearHttpStatusInfo(); bool dnodeIsFirstDeploy(); bool dnodeIsMasterEp(char *ep); diff --git a/src/plugins/monitor/src/monMain.c b/src/plugins/monitor/src/monMain.c index 2462d76df6..b98ada4a97 100644 --- a/src/plugins/monitor/src/monMain.c +++ b/src/plugins/monitor/src/monMain.c @@ -1208,13 +1208,12 @@ static void monSaveHttpReqInfo() { char * sql = tsMonitor.sql; int32_t pos = snprintf(sql, SQL_LENGTH, "insert into %s.restful_%d values(%" PRId64, tsMonitorDbName, dnodeGetDnodeId(), ts); - SDnodeStatisInfo info = dnodeGetStatisInfo(); - pos += snprintf(sql + pos, SQL_LENGTH, ", %d", info.httpReqNum); for (int32_t i = 0; i < tListLen(monHttpStatusTable); ++i) { - int32_t status = info.httpStatusCodeErrs[i]; + int32_t status = dnodeGetHttpStatusInfo(i); pos += snprintf(sql + pos, SQL_LENGTH, ", %d", status); } pos += snprintf(sql + pos, SQL_LENGTH, ")"); + dnodeClearHttpStatusInfo(); monError("sql:%s", sql); -- GitLab