TDengine/include/libs/monitor/clientMonitor.h

92 lines
2.6 KiB
C
Raw Normal View History

2023-11-02 10:44:18 +00:00
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_CLIENT_MONITOR_H
#define TDENGINE_CLIENT_MONITOR_H
#ifdef __cplusplus
extern "C" {
#endif
#include "taos_monitor.h"
#include "thash.h"
#include "query.h"
2024-06-19 10:54:26 +00:00
#include "tqueue.h"
2024-10-31 09:33:08 +00:00
#include "clientInt.h"
2023-11-02 10:44:18 +00:00
typedef enum {
2024-02-02 05:39:31 +00:00
SQL_RESULT_SUCCESS = 0,
SQL_RESULT_FAILED = 1,
SQL_RESULT_CANCEL = 2,
} SQL_RESULT_CODE;
typedef enum {
SLOW_LOG_WRITE = 0,
SLOW_LOG_READ_RUNNING = 1,
SLOW_LOG_READ_BEGINNIG = 2,
SLOW_LOG_READ_QUIT = 3,
} SLOW_LOG_QUEUE_TYPE;
2024-07-05 08:12:13 +00:00
static char* queueTypeStr[] = {
2024-07-05 06:03:12 +00:00
"SLOW_LOG_WRITE",
"SLOW_LOG_READ_RUNNING",
"SLOW_LOG_READ_BEGINNIG",
"SLOW_LOG_READ_QUIT"
};
#define SLOW_LOG_SEND_SIZE_MAX 1024*1024
2024-02-02 05:39:31 +00:00
2023-11-02 10:44:18 +00:00
typedef struct {
2024-06-19 10:54:26 +00:00
int64_t clusterId;
2023-11-02 10:44:18 +00:00
taos_collector_registry_t* registry;
taos_collector_t* colector;
SHashObj* counters;
2024-06-22 15:33:04 +00:00
void* timer;
2024-06-19 10:54:26 +00:00
} MonitorClient;
2024-06-22 15:33:04 +00:00
typedef struct {
TdFilePtr pFile;
int64_t lastCheckTime;
char path[PATH_MAX];
int64_t offset;
2024-06-22 15:33:04 +00:00
} SlowLogClient;
2024-06-19 10:54:26 +00:00
typedef struct {
int64_t clusterId;
SLOW_LOG_QUEUE_TYPE type;
char* data;
int64_t offset;
TdFilePtr pFile;
char* fileName;
2024-06-19 10:54:26 +00:00
} MonitorSlowLogData;
void monitorClose();
int32_t monitorInit();
2024-06-19 10:54:26 +00:00
void monitorClientSQLReqInit(int64_t clusterKey);
void monitorClientSlowQueryInit(int64_t clusterId);
void monitorCreateClient(int64_t clusterId);
void monitorCreateClientCounter(int64_t clusterId, const char* name, const char* help, size_t label_key_count, const char** label_keys);
void monitorCounterInc(int64_t clusterId, const char* counterName, const char** label_values);
const char* monitorResultStr(SQL_RESULT_CODE code);
int32_t monitorPutData2MonitorQueue(MonitorSlowLogData data);
2024-10-31 09:33:08 +00:00
void clientOperateReport(SRequestObj* pRequest);
2023-11-02 10:44:18 +00:00
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_CLIENT_MONITOR_H