TSG-21854 TFE使用fieldstat4序列化Manipulation Policy的metric并输出到kafka

This commit is contained in:
fengweihao
2024-07-26 16:50:51 +08:00
parent a59b939033
commit 83f51432b1
17 changed files with 382 additions and 406 deletions

View File

@@ -9,6 +9,9 @@ extern "C"
#include <tfe_utils.h>
#include "fieldstat/fieldstat_easy.h"
#define FIELDSTAT_TAG_INIT(ptr, index, _key, _type, _value) \
do { ptr[index].key = _key; ptr[index].type = _type; ptr[index].value_longlong = _value; } while(0)
enum metric_columns_index
{
COLUMN_HIT_COUNT = 0,
@@ -29,18 +32,45 @@ enum metric_tags_index
TAG_MAX
};
struct tfe_fieldstat_easy_t
struct fieldstat_easy_intercept
{
int table_id;
int max_thread;
int hit_count_idx;
int in_bytes_idx;
int out_bytes_idx;
int in_pkts_idx;
int out_pkts_idx;
int output_fs_interval_ms;
struct fieldstat_easy *fs;
};
struct filedstat_easy_manipulation
{
int table_id;
int max_thread;
struct fieldstat_tag **tags;
int counter_array[COLUMN_MAX];
struct fieldstat_easy *fseasy;
struct fieldstat_easy *fs;
};
struct tfe_fieldstat_easy_t *tfe_fieldstat_easy_create(char *app_name, char *outpath, int cycle, int max_thread, void *local_logger);
struct tfe_fieldstat_easy_t
{
pthread_t tid;
int thr_is_runing;
int thr_need_exit;
int output_kafka_interval_ms;
struct fieldstat_easy_intercept *intercept;
struct filedstat_easy_manipulation *manipulation;
};
int tfe_fieldstat_get_output_interval(struct fieldstat_easy_intercept *fieldstat);
int tfe_fieldstat_intercept_incrby(struct fieldstat_easy_intercept *fieldstat, void *val_data, int thread_index);
int tfe_fieldstat_manipulation_incrby(struct filedstat_easy_manipulation *fieldstat, unsigned int counter_id, long long value, const struct fieldstat_tag tags[], int n_tags, int thread_id);
struct tfe_fieldstat_easy_t *tfe_fieldstat_easy_create(int output_kafka_interval_ms);
struct fieldstat_easy_intercept *tfe_fieldstat_easy_intercept_create(char *app_name, int max_thread, int output_fs_interval_ms, void *local_logger);
struct filedstat_easy_manipulation *tfe_fieldstat_easy_manipulation_create(char *app_name, char *outpath, int cycle, int max_thread, void *local_logger);
void tfe_fieldstat_easy_destroy(struct tfe_fieldstat_easy_t *fieldstat);
int tfe_fieldstat_easy_incrby(struct tfe_fieldstat_easy_t *fieldstat, unsigned int counter_id, long long value, const struct fieldstat_tag tags[], int n_tags, int thread_id);
#ifdef __cpluscplus
}