enh: insert/delete sql count
This commit is contained in:
parent
a59fd502cf
commit
b554887d4d
|
@ -438,7 +438,14 @@ void clientSlowQueryMonitorInit(const char* clusterKey);
|
||||||
void SlowQueryLog(int64_t rid, bool killed, int32_t code, int32_t cost);
|
void SlowQueryLog(int64_t rid, bool killed, int32_t code, int32_t cost);
|
||||||
|
|
||||||
void clientSQLReqMonitorInit(const char* clusterKey);
|
void clientSQLReqMonitorInit(const char* clusterKey);
|
||||||
void sqlReqLog(int64_t rid, bool killed, int32_t code);
|
|
||||||
|
enum {
|
||||||
|
MONITORSQLTYPESELECT = 0,
|
||||||
|
MONITORSQLTYPEINSERT = 1,
|
||||||
|
MONITORSQLTYPEDELETE = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
void sqlReqLog(int64_t rid, bool killed, int32_t code, int8_t type);
|
||||||
|
|
||||||
void clientMonitorClose(const char* clusterKey);
|
void clientMonitorClose(const char* clusterKey);
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,7 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
||||||
pRequest->metric.planCostUs, pRequest->metric.execCostUs);
|
pRequest->metric.planCostUs, pRequest->metric.execCostUs);
|
||||||
atomic_add_fetch_64((int64_t *)&pActivity->insertElapsedTime, duration);
|
atomic_add_fetch_64((int64_t *)&pActivity->insertElapsedTime, duration);
|
||||||
reqType = SLOW_LOG_TYPE_INSERT;
|
reqType = SLOW_LOG_TYPE_INSERT;
|
||||||
|
sqlReqLog(pTscObj->id, pRequest->killed, pRequest->code, MONITORSQLTYPEINSERT);
|
||||||
} else if (QUERY_NODE_SELECT_STMT == pRequest->stmtType) {
|
} else if (QUERY_NODE_SELECT_STMT == pRequest->stmtType) {
|
||||||
tscDebug("query duration %" PRId64 "us: parseCost:%" PRId64 "us, ctgCost:%" PRId64 "us, analyseCost:%" PRId64
|
tscDebug("query duration %" PRId64 "us: parseCost:%" PRId64 "us, ctgCost:%" PRId64 "us, analyseCost:%" PRId64
|
||||||
"us, planCost:%" PRId64 "us, exec:%" PRId64 "us",
|
"us, planCost:%" PRId64 "us, exec:%" PRId64 "us",
|
||||||
|
@ -105,8 +106,10 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
||||||
pRequest->metric.planCostUs, pRequest->metric.execCostUs);
|
pRequest->metric.planCostUs, pRequest->metric.execCostUs);
|
||||||
|
|
||||||
atomic_add_fetch_64((int64_t *)&pActivity->queryElapsedTime, duration);
|
atomic_add_fetch_64((int64_t *)&pActivity->queryElapsedTime, duration);
|
||||||
sqlReqLog(pTscObj->id, pRequest->killed, pRequest->code);
|
|
||||||
reqType = SLOW_LOG_TYPE_QUERY;
|
reqType = SLOW_LOG_TYPE_QUERY;
|
||||||
|
sqlReqLog(pTscObj->id, pRequest->killed, pRequest->code, MONITORSQLTYPESELECT);
|
||||||
|
} else if (QUERY_NODE_DELETE_STMT == pRequest->stmtType) {
|
||||||
|
sqlReqLog(pTscObj->id, pRequest->killed, pRequest->code, MONITORSQLTYPEDELETE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,24 @@ void clientSQLReqMonitorInit(const char* clusterKey) {
|
||||||
createClusterCounter(clusterKey, selectMonitorName, selectMonitorHelp, selectMonitorLabelCount, selectMonitorLabels);
|
createClusterCounter(clusterKey, selectMonitorName, selectMonitorHelp, selectMonitorLabelCount, selectMonitorLabels);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clientSQLReqLog(const char* clusterKey, const char* user, SQL_RESULT_CODE result) {
|
void clientSQLReqLog(const char* clusterKey, const char* user, SQL_RESULT_CODE result, int8_t type) {
|
||||||
const char* selectMonitorLabelValues[] = {defaultClusterID, "select", user, resultStr(result)};
|
const char* typeStr;
|
||||||
|
switch (type) {
|
||||||
|
case MONITORSQLTYPEDELETE:
|
||||||
|
typeStr = "delete";
|
||||||
|
break;
|
||||||
|
case MONITORSQLTYPEINSERT:
|
||||||
|
typeStr = "insert";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
typeStr = "select";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const char* selectMonitorLabelValues[] = {defaultClusterID, typeStr, user, resultStr(result)};
|
||||||
taosClusterCounterInc(clusterKey, selectMonitorName, selectMonitorLabelValues);
|
taosClusterCounterInc(clusterKey, selectMonitorName, selectMonitorLabelValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sqlReqLog(int64_t rid, bool killed, int32_t code) {
|
void sqlReqLog(int64_t rid, bool killed, int32_t code, int8_t type) {
|
||||||
if (!tsEnableMonitor) return;
|
if (!tsEnableMonitor) return;
|
||||||
SQL_RESULT_CODE result = SQL_RESULT_SUCCESS;
|
SQL_RESULT_CODE result = SQL_RESULT_SUCCESS;
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
@ -53,7 +65,7 @@ void sqlReqLog(int64_t rid, bool killed, int32_t code) {
|
||||||
if (pTscObj->pAppInfo == NULL) {
|
if (pTscObj->pAppInfo == NULL) {
|
||||||
tscLog("sqlReqLog, not found pAppInfo");
|
tscLog("sqlReqLog, not found pAppInfo");
|
||||||
} else {
|
} else {
|
||||||
clientSQLReqLog(pTscObj->pAppInfo->instKey, pTscObj->user, result);
|
clientSQLReqLog(pTscObj->pAppInfo->instKey, pTscObj->user, result, type);
|
||||||
}
|
}
|
||||||
releaseTscObj(rid);
|
releaseTscObj(rid);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue