From 692d589a06d024a6a0459a89f7319ef5904c744b 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 request metrics --- src/inc/dnode.h | 3 +++ src/vnode/src/vnodeWrite.c | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/inc/dnode.h b/src/inc/dnode.h index 8decb02023..0ee2b78d80 100644 --- a/src/inc/dnode.h +++ b/src/inc/dnode.h @@ -26,6 +26,9 @@ extern "C" { typedef struct { int32_t queryReqNum; int32_t submitReqNum; + int32_t submitReqSucNum; + int32_t submitRowNum; + int32_t submitRowSucNum; int32_t httpReqNum; } SStatisInfo; diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 35c2ab72df..64fca2d52a 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -27,6 +27,10 @@ #define MAX_QUEUED_MSG_NUM 100000 #define MAX_QUEUED_MSG_SIZE 1024*1024*1024 //1GB +static int32_t tsSubmitReqSucNum = 0; +static int32_t tsSubmitRowNum = 0; +static int32_t tsSubmitRowSucNum = 0; + extern void * tsDnodeTmr; static int32_t (*vnodeProcessWriteMsgFp[TSDB_MSG_TYPE_MAX])(SVnodeObj *, void *pCont, SRspRet *); static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *); @@ -163,7 +167,13 @@ static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pR pRsp = pRet->rsp; } - if (tsdbInsertData(pVnode->tsdb, pCont, pRsp) < 0) code = terrno; + if (tsdbInsertData(pVnode->tsdb, pCont, pRsp) < 0) { + code = terrno; + } else { + atomic_fetch_add_32(&tsSubmitReqSucNum, 1); + } + atomic_fetch_add_32(&tsSubmitRowNum, pRsp->numOfRows); + atomic_fetch_add_32(&tsSubmitRowSucNum, pRsp->affectedRows); return code; } @@ -425,3 +435,15 @@ void vnodeWaitWriteCompleted(SVnodeObj *pVnode) { if (extraSleep) taosMsleep(900); } + +void vnodeGetStatisInfo(SStatisInfo *info) { + info->submitReqSucNum = atomic_load_32(&tsSubmitReqSucNum); + info->submitRowNum = atomic_load_32(&tsSubmitRowNum); + info->submitRowSucNum = atomic_load_32(&tsSubmitRowSucNum); +} + +void vnodeClearStatisInfo() { + atomic_exchange_32(&tsSubmitReqSucNum, 0); + atomic_exchange_32(&tsSubmitRowNum, 0); + atomic_exchange_32(&tsSubmitRowSucNum, 0); +} -- GitLab