summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryangwei <[email protected]>2024-07-16 11:27:26 +0800
committeryangwei <[email protected]>2024-07-16 11:27:26 +0800
commit13f3196ee66d266e00be285fd96fef29d625345a (patch)
treead83f1ca801abb65e606d907bc82767dff57206c
parent524cc3851c3c1e145a0f6815bbbe1f0152c4d4c2 (diff)
🌈 style(rename fieldstat_tag): from fieldstat_tag to field_tagv3.1.0
-rw-r--r--inc/fieldstat.h32
-rw-r--r--src/fieldstat.cpp26
-rw-r--r--src/fieldstat_dynamic.cpp42
-rw-r--r--src/fieldstat_internal.h6
-rw-r--r--test/fieldstat_test.cpp10
-rw-r--r--test/src/gtest_dynamic_fieldstat.cpp40
-rw-r--r--test/src/gtest_dynamic_fieldstat_output.cpp4
-rw-r--r--test/src/gtest_fieldstat_interface.cpp2
8 files changed, 81 insertions, 81 deletions
diff --git a/inc/fieldstat.h b/inc/fieldstat.h
index 4d38bf3..3b37204 100644
--- a/inc/fieldstat.h
+++ b/inc/fieldstat.h
@@ -14,7 +14,7 @@ enum field_type
};
-struct fieldstat_tag{
+struct field_tag{
const char *key;
int value_type; // 0 int, 1 double, 2 str
union{
@@ -99,7 +99,7 @@ int fieldstat_set_output_interval(struct fieldstat_instance *instance, int milli
* @param n_tag Size of tags[]
* @return metric id. -1 is failed. >=0 is success.
*/
-int fieldstat_register(struct fieldstat_instance *instance, enum field_type type, const char *field_name, const struct fieldstat_tag tags[], size_t n_tag);
+int fieldstat_register(struct fieldstat_instance *instance, enum field_type type, const char *field_name, const struct field_tag tags[], size_t n_tag);
/**
* Register table. Max table num is 64. Max table columns is 64.
* @param instance The fieldstat instance.
@@ -120,7 +120,7 @@ int fieldstat_register_table(struct fieldstat_instance *instance, const char *ta
* @param output_metric_ids Output metric ids
* @return -1 is failed. 0 is success.
*/
-int fieldstat_register_table_row(struct fieldstat_instance *instance, int table_id, const char *row_name, const struct fieldstat_tag tags[],size_t n_tag, int output_metric_ids[]);
+int fieldstat_register_table_row(struct fieldstat_instance *instance, int table_id, const char *row_name, const struct field_tag tags[],size_t n_tag, int output_metric_ids[]);
/**
* Increment fieldstat metric value by metric_id.
* @param instance The fieldstat instance.
@@ -173,7 +173,7 @@ void fieldstat_passive_output(struct fieldstat_instance *instance);
* @param output_window The of output data. 1: output the data in the time interval window, 0: output data all the time.
* @return metric id: -1 is failed, >= 0 is success
*/
-int fieldstat_register_distribution(struct fieldstat_instance *instance, const char *field_name, const struct fieldstat_tag tags[], size_t n_tag,
+int fieldstat_register_distribution(struct fieldstat_instance *instance, const char *field_name, const struct field_tag tags[], size_t n_tag,
const char *upper_inclusive_bounds, const long long lowest_trackable_value, long long highest_trackable_value, int significant_figures, int output_window);
/**
@@ -194,7 +194,7 @@ int fieldstat_register_distribution(struct fieldstat_instance *instance, const c
* @param output_window The of output data. 1: output the data in the time interval window, 0: output data all the time.
* @return metric id: -1 is failed, >= 0 is success
*/
-int fieldstat_register_summary(struct fieldstat_instance *instance, const char *field_name, const struct fieldstat_tag tags[], size_t n_tag,
+int fieldstat_register_summary(struct fieldstat_instance *instance, const char *field_name, const struct field_tag tags[], size_t n_tag,
const char *quantiles, const long long lowest_trackable_value, long long highest_trackable_value, int significant_figures, int output_window);
/**
@@ -261,7 +261,7 @@ int fieldstat_register_dynamic_table(struct fieldstat_dynamic_instance *instance
* @param thread_id The thread id of the call.
* @return -1 is failed. 0 is success.
*/
-int fieldstat_dynamic_metric_value_incrby(struct fieldstat_dynamic_instance *instance, enum field_type type, const char *field_name, long long value, const struct fieldstat_tag tags[], size_t n_tags, int thread_id);
+int fieldstat_dynamic_metric_value_incrby(struct fieldstat_dynamic_instance *instance, enum field_type type, const char *field_name, long long value, const struct field_tag tags[], size_t n_tags, int thread_id);
/**
* fieldstat dynamic instance metric value set operate. metirc type in[gauge, counter]
* @param instance The fieldstat dynamic instance.
@@ -273,7 +273,7 @@ int fieldstat_dynamic_metric_value_incrby(struct fieldstat_dynamic_instance *ins
* @param thread_id The thread id of the call.
* @return -1 is failed. 0 is success.
*/
-int fieldstat_dynamic_metric_value_set(struct fieldstat_dynamic_instance *instance, enum field_type type, const char *field_name, long long value, const struct fieldstat_tag tags[], size_t n_tags, int thread_id);
+int fieldstat_dynamic_metric_value_set(struct fieldstat_dynamic_instance *instance, enum field_type type, const char *field_name, long long value, const struct field_tag tags[], size_t n_tags, int thread_id);
/**
* fieldstat dynamic instance metric value decrment operate. metirc type in[gauge, counter]
* @param instance The fieldstat dynamic instance.
@@ -285,7 +285,7 @@ int fieldstat_dynamic_metric_value_set(struct fieldstat_dynamic_instance *instan
* @param thread_id The thread id of the call.
* @return -1 is failed. 0 is success.
*/
-int fieldstat_dynamic_metric_value_decrby(struct fieldstat_dynamic_instance *instance, enum field_type type, const char *field_name, long long value, const struct fieldstat_tag tags[], size_t n_tags, int thread_id);
+int fieldstat_dynamic_metric_value_decrby(struct fieldstat_dynamic_instance *instance, enum field_type type, const char *field_name, long long value, const struct field_tag tags[], size_t n_tags, int thread_id);
/**
* fieldstat dynamic instance table metric value incrment operate.
* @param instance The fieldstat dynamic instance.
@@ -298,7 +298,7 @@ int fieldstat_dynamic_metric_value_decrby(struct fieldstat_dynamic_instance *ins
* @param thread_id The thread id of the call.
* @return -1 is failed. 0 is success.
*/
-int fieldstat_dynamic_table_metric_value_incrby(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, long long value, const struct fieldstat_tag tags[], size_t n_tags, int thread_id);
+int fieldstat_dynamic_table_metric_value_incrby(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, long long value, const struct field_tag tags[], size_t n_tags, int thread_id);
/**
* fieldstat dynamic instance table metric value set operate.
* @param instance The fieldstat dynamic instance.
@@ -311,7 +311,7 @@ int fieldstat_dynamic_table_metric_value_incrby(struct fieldstat_dynamic_instanc
* @param thread_id The thread id of the call.
* @return -1 is failed. 0 is success.
*/
-int fieldstat_dynamic_table_metric_value_set(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, long long value, const struct fieldstat_tag tags[], size_t n_tags, int thread_id);
+int fieldstat_dynamic_table_metric_value_set(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, long long value, const struct field_tag tags[], size_t n_tags, int thread_id);
/**
* fieldstat dynamic instance table metric value decrment operate.
* @param instance The fieldstat dynamic instance.
@@ -324,7 +324,7 @@ int fieldstat_dynamic_table_metric_value_set(struct fieldstat_dynamic_instance *
* @param thread_id The thread id of the call.
* @return -1 is failed. 0 is success.
*/
-int fieldstat_dynamic_table_metric_value_decrby(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, long long value, const struct fieldstat_tag tags[], size_t n_tags, int thread_id);
+int fieldstat_dynamic_table_metric_value_decrby(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, long long value, const struct field_tag tags[], size_t n_tags, int thread_id);
/**
* fieldstat instance free.
* @param instance The fieldstat instance need to free.
@@ -347,7 +347,7 @@ void fieldstat_dynamic_instance_free(struct fieldstat_dynamic_instance *instance
* @param thread_id The thread id of the call.
* @return long long value.
*/
-long long fieldstat_dynamic_table_metric_value_get(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, const struct fieldstat_tag tags[], size_t n_tags, int thread_id);
+long long fieldstat_dynamic_table_metric_value_get(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, const struct field_tag tags[], size_t n_tags, int thread_id);
/**
* fieldstat dynamic instance metric value get operate. metirc type in[gauge, counter]
* @param instance The fieldstat dynamic instance.
@@ -357,7 +357,7 @@ long long fieldstat_dynamic_table_metric_value_get(struct fieldstat_dynamic_inst
* @param thread_id The thread id of the call.
* @return long long value.
*/
-long long fieldstat_dynamic_metric_value_get(struct fieldstat_dynamic_instance *instance, const char *field_name, const struct fieldstat_tag tags[], size_t n_tags, int thread_id);
+long long fieldstat_dynamic_metric_value_get(struct fieldstat_dynamic_instance *instance, const char *field_name, const struct field_tag tags[], size_t n_tags, int thread_id);
/**
* fieldstat set metric ratio parameter.
* @param instance The fieldstat instance.
@@ -395,7 +395,7 @@ int fieldstat_dynamic_table_row_metric_values_incrby(
const char *row_name,
long long values[],
size_t n_values,
- const struct fieldstat_tag tags[],
+ const struct field_tag tags[],
size_t n_tags,
int thread_id);
@@ -417,7 +417,7 @@ int fieldstat_dynamic_table_row_metric_values_decrby(
const char *row_name,
long long values[],
size_t n_values,
- const struct fieldstat_tag tags[],
+ const struct field_tag tags[],
size_t n_tags,
int thread_id);
@@ -439,7 +439,7 @@ int fieldstat_dynamic_table_row_metric_values_set(
const char *row_name,
long long values[],
size_t n_values,
- const struct fieldstat_tag tags[],
+ const struct field_tag tags[],
size_t n_tags,
int thread_id);
diff --git a/src/fieldstat.cpp b/src/fieldstat.cpp
index 53d64a3..8e5cdf8 100644
--- a/src/fieldstat.cpp
+++ b/src/fieldstat.cpp
@@ -69,14 +69,14 @@ int is_valid_tag_value(const char* value)
}
-int is_valid_tags(const struct fieldstat_tag *tags, size_t n_tags)
+int is_valid_tags(const struct field_tag *tags, size_t n_tags)
{
int i = 0;
- struct fieldstat_tag *tag = NULL;
+ struct field_tag *tag = NULL;
for(i = 0; i < (int)n_tags; i++)
{
- tag = (struct fieldstat_tag *)&tags[i];
+ tag = (struct field_tag *)&tags[i];
if (0 == is_valid_field_name(tag->key))
{
return 0;
@@ -172,16 +172,16 @@ struct metric * get_metric(struct fieldstat_instance *instance, int metric_id)
return metric;
}
-void add_tags_to_metric(const struct fieldstat_tag tags[], size_t n_tag, char *tag_key[], char *tag_value[])
+void add_tags_to_metric(const struct field_tag tags[], size_t n_tag, char *tag_key[], char *tag_value[])
{
int i = 0;
- struct fieldstat_tag *tag = NULL;
+ struct field_tag *tag = NULL;
char str_longlong[32] = {0};
char str_double[32] = {0};
for(i = 0; i < (int)n_tag; i++)
{
- tag = (struct fieldstat_tag *)&tags[i];
+ tag = (struct field_tag *)&tags[i];
tag_key[i] = __str_dup(tag->key);
switch(tag->value_type)
{
@@ -205,7 +205,7 @@ void add_tags_to_metric(const struct fieldstat_tag tags[], size_t n_tag, char *t
}
}
-struct metric * metric_new(enum field_type type, const char *field_name, const struct fieldstat_tag tags[], size_t n_tag)
+struct metric * metric_new(enum field_type type, const char *field_name, const struct field_tag tags[], size_t n_tag)
{
struct metric *metric = (struct metric*)calloc(1, sizeof(struct metric));
metric->field_name = __str_dup(field_name);
@@ -507,7 +507,7 @@ int fieldstat_set_statsd_server(struct fieldstat_instance *instance, const char
return 0;
}
-int fieldstat_register(struct fieldstat_instance *instance, enum field_type type, const char *field_name, const struct fieldstat_tag tags[], size_t n_tag)
+int fieldstat_register(struct fieldstat_instance *instance, enum field_type type, const char *field_name, const struct field_tag tags[], size_t n_tag)
{
int metric_id = 0;
struct metric *metric = NULL;
@@ -899,7 +899,7 @@ struct table_line ** read_table_line_slot(struct table_metric *table, int line_i
return (struct table_line **)&(line[in_block_index]);
}
-struct table_line *table_line_new(const char *name, const struct fieldstat_tag tags[],size_t n_tag)
+struct table_line *table_line_new(const char *name, const struct field_tag tags[],size_t n_tag)
{
struct table_line *table_line = (struct table_line *)calloc(1, sizeof(struct table_line));
@@ -939,7 +939,7 @@ void table_line_free(struct table_line *table_line)
-int fieldstat_register_table_row(struct fieldstat_instance * instance, int table_id, const char *row_name, const struct fieldstat_tag tags[], size_t n_tag, int output_metric_ids[])
+int fieldstat_register_table_row(struct fieldstat_instance * instance, int table_id, const char *row_name, const struct field_tag tags[], size_t n_tag, int output_metric_ids[])
{
int metric_id = 0;
struct metric *metric = NULL;
@@ -1118,7 +1118,7 @@ error_out:
}
-static int fieldstat_register_histogram(struct fieldstat_instance *instance, enum field_type type, const char *field_name, const struct fieldstat_tag tags[], size_t n_tag,
+static int fieldstat_register_histogram(struct fieldstat_instance *instance, enum field_type type, const char *field_name, const struct field_tag tags[], size_t n_tag,
const char * bins, long long lowest_trackable_value, long long highest_trackable_value, int significant_figures, int output_window)
{
struct metric *metric = NULL;
@@ -1181,14 +1181,14 @@ static int fieldstat_register_histogram(struct fieldstat_instance *instance, enu
}
-int fieldstat_register_distribution(struct fieldstat_instance *instance, const char *field_name,const struct fieldstat_tag tags[], size_t n_tag,
+int fieldstat_register_distribution(struct fieldstat_instance *instance, const char *field_name,const struct field_tag tags[], size_t n_tag,
const char * bins, long long lowest_trackable_value, long long highest_trackable_value, int significant_figures, int output_window)
{
return fieldstat_register_histogram(instance, FILED_TYPE_HISTOGRAM, field_name, tags, n_tag,
bins, lowest_trackable_value, highest_trackable_value, significant_figures, output_window);
}
-int fieldstat_register_summary(struct fieldstat_instance *instance, const char *field_name, const struct fieldstat_tag tags[], size_t n_tag,
+int fieldstat_register_summary(struct fieldstat_instance *instance, const char *field_name, const struct field_tag tags[], size_t n_tag,
const char * bins, long long lowest_trackable_value, long long highest_trackable_value, int significant_figures, int output_window)
{
return fieldstat_register_histogram(instance, FIELD_TYPE_SUMMARY, field_name, tags, n_tag,
diff --git a/src/fieldstat_dynamic.cpp b/src/fieldstat_dynamic.cpp
index 2083c11..375de17 100644
--- a/src/fieldstat_dynamic.cpp
+++ b/src/fieldstat_dynamic.cpp
@@ -298,7 +298,7 @@ int fieldstat_register_dynamic_table(struct fieldstat_dynamic_instance *instance
}
-static int build_dynamic_metric_key(int table_id, const char *field_name, const struct fieldstat_tag tags[], size_t n_tags, size_t out_key_size, char *out_key) {
+static int build_dynamic_metric_key(int table_id, const char *field_name, const struct field_tag tags[], size_t n_tags, size_t out_key_size, char *out_key) {
unsigned int used_len = 0;
/* part1: field name */
@@ -323,7 +323,7 @@ static int build_dynamic_metric_key(int table_id, const char *field_name, const
/* part3: tags and value */
for (unsigned int i = 0; i < n_tags; i++) {
- struct fieldstat_tag *tag = (struct fieldstat_tag *) &tags[i];
+ struct field_tag *tag = (struct field_tag *) &tags[i];
/* tag key len */
unsigned int tag_key_len = strlen(tag->key) + 1;
@@ -375,7 +375,7 @@ static int build_dynamic_metric_key(int table_id, const char *field_name, const
return (int) used_len;
}
-static struct metric * read_dynamic_metric(struct fieldstat_dynamic_instance *instance, int table_id, int column_id, const char *field_name, const struct fieldstat_tag tags[], size_t n_tags, int thread_id)
+static struct metric * read_dynamic_metric(struct fieldstat_dynamic_instance *instance, int table_id, int column_id, const char *field_name, const struct field_tag tags[], size_t n_tags, int thread_id)
{
struct dynamic_metric **head = &instance->n_thread_dynamic_metric[thread_id];
struct dynamic_metric *find = NULL;
@@ -425,7 +425,7 @@ static struct metric * read_dynamic_metric(struct fieldstat_dynamic_instance *in
return find->metrics[column_id];
}
-static struct metric * create_dynamic_table_metric(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, const struct fieldstat_tag tags[], size_t n_tags, int thread_id)
+static struct metric * create_dynamic_table_metric(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, const struct field_tag tags[], size_t n_tags, int thread_id)
{
int i = 0;
struct dynamic_metric **head = NULL;
@@ -513,7 +513,7 @@ static struct metric * create_dynamic_table_metric(struct fieldstat_dynamic_inst
}
-static struct metric * create_dynamic_metric(struct fieldstat_dynamic_instance *instance, enum field_type type, const char *field_name, long long value, const struct fieldstat_tag tags[], size_t n_tags, int thread_id)
+static struct metric * create_dynamic_metric(struct fieldstat_dynamic_instance *instance, enum field_type type, const char *field_name, long long value, const struct field_tag tags[], size_t n_tags, int thread_id)
{
struct dynamic_metric **head = NULL;
struct dynamic_metric *insert = NULL;
@@ -582,7 +582,7 @@ static struct metric * create_dynamic_metric(struct fieldstat_dynamic_instance *
}
-static int fieldstat_dynamic_metric_value_operate(struct fieldstat_dynamic_instance *instance, enum field_op op, enum field_type type, const char *field_name, long long value, const struct fieldstat_tag tags[], size_t n_tags, int thread_id)
+static int fieldstat_dynamic_metric_value_operate(struct fieldstat_dynamic_instance *instance, enum field_op op, enum field_type type, const char *field_name, long long value, const struct field_tag tags[], size_t n_tags, int thread_id)
{
struct metric * metric = NULL;
@@ -602,22 +602,22 @@ static int fieldstat_dynamic_metric_value_operate(struct fieldstat_dynamic_insta
}
-int fieldstat_dynamic_metric_value_incrby(struct fieldstat_dynamic_instance *instance, enum field_type type, const char *field_name, long long value, const struct fieldstat_tag tags[], size_t n_tags, int thread_id)
+int fieldstat_dynamic_metric_value_incrby(struct fieldstat_dynamic_instance *instance, enum field_type type, const char *field_name, long long value, const struct field_tag tags[], size_t n_tags, int thread_id)
{
return fieldstat_dynamic_metric_value_operate(instance, FS_OP_ADD, type, field_name, value, tags, n_tags, thread_id);
}
-int fieldstat_dynamic_metric_value_set(struct fieldstat_dynamic_instance *instance, enum field_type type, const char *field_name, long long value, const struct fieldstat_tag tags[], size_t n_tags, int thread_id)
+int fieldstat_dynamic_metric_value_set(struct fieldstat_dynamic_instance *instance, enum field_type type, const char *field_name, long long value, const struct field_tag tags[], size_t n_tags, int thread_id)
{
return fieldstat_dynamic_metric_value_operate(instance, FS_OP_SET, type, field_name, value, tags, n_tags, thread_id);
}
-int fieldstat_dynamic_metric_value_decrby(struct fieldstat_dynamic_instance *instance, enum field_type type, const char *field_name, long long value, const struct fieldstat_tag tags[], size_t n_tags, int thread_id)
+int fieldstat_dynamic_metric_value_decrby(struct fieldstat_dynamic_instance *instance, enum field_type type, const char *field_name, long long value, const struct field_tag tags[], size_t n_tags, int thread_id)
{
return fieldstat_dynamic_metric_value_operate(instance, FS_OP_SUB, type, field_name, value, tags, n_tags, thread_id);
}
-int fieldstat_dynamic_table_metric_value_operate(struct fieldstat_dynamic_instance *instance, enum field_op op, int table_id, unsigned int column_id, const char *row_name, long long value, const struct fieldstat_tag tags[], size_t n_tags, int thread_id)
+int fieldstat_dynamic_table_metric_value_operate(struct fieldstat_dynamic_instance *instance, enum field_op op, int table_id, unsigned int column_id, const char *row_name, long long value, const struct field_tag tags[], size_t n_tags, int thread_id)
{
struct metric * metric = NULL;
metric = read_dynamic_metric(instance, table_id, column_id, row_name, tags, n_tags, thread_id);
@@ -634,22 +634,22 @@ int fieldstat_dynamic_table_metric_value_operate(struct fieldstat_dynamic_instan
return 0;
}
-int fieldstat_dynamic_table_metric_value_incrby(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, long long value, const struct fieldstat_tag tags[], size_t n_tags, int thread_id)
+int fieldstat_dynamic_table_metric_value_incrby(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, long long value, const struct field_tag tags[], size_t n_tags, int thread_id)
{
return fieldstat_dynamic_table_metric_value_operate( instance, FS_OP_ADD, table_id, column_id, row_name, value, tags, n_tags, thread_id);
}
-int fieldstat_dynamic_table_metric_value_set(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, long long value, const struct fieldstat_tag tags[], size_t n_tags, int thread_id)
+int fieldstat_dynamic_table_metric_value_set(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, long long value, const struct field_tag tags[], size_t n_tags, int thread_id)
{
return fieldstat_dynamic_table_metric_value_operate(instance, FS_OP_SET, table_id, column_id, row_name, value, tags, n_tags, thread_id);
}
-int fieldstat_dynamic_table_metric_value_decrby(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, long long value, const struct fieldstat_tag tags[], size_t n_tags, int thread_id)
+int fieldstat_dynamic_table_metric_value_decrby(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, long long value, const struct field_tag tags[], size_t n_tags, int thread_id)
{
return fieldstat_dynamic_table_metric_value_operate( instance, FS_OP_SUB, table_id, column_id, row_name, value, tags, n_tags, thread_id);
}
-static long long dynamic_metric_value_read(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *field_name, const struct fieldstat_tag tags[], size_t n_tags, int thread_id)
+static long long dynamic_metric_value_read(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *field_name, const struct field_tag tags[], size_t n_tags, int thread_id)
{
long long value = 0;
struct metric * metric = NULL;
@@ -663,14 +663,14 @@ static long long dynamic_metric_value_read(struct fieldstat_dynamic_instance *in
return value;
}
-long long fieldstat_dynamic_metric_value_get(struct fieldstat_dynamic_instance *instance, const char *field_name, const struct fieldstat_tag tags[], size_t n_tags, int thread_id)
+long long fieldstat_dynamic_metric_value_get(struct fieldstat_dynamic_instance *instance, const char *field_name, const struct field_tag tags[], size_t n_tags, int thread_id)
{
long long value = 0;
value = dynamic_metric_value_read(instance, -1, -1, field_name, tags, n_tags, thread_id);
return value;
}
-long long fieldstat_dynamic_table_metric_value_get(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, const struct fieldstat_tag tags[], size_t n_tags, int thread_id)
+long long fieldstat_dynamic_table_metric_value_get(struct fieldstat_dynamic_instance *instance, int table_id, unsigned int column_id, const char *row_name, const struct field_tag tags[], size_t n_tags, int thread_id)
{
long long value = 0;
value = dynamic_metric_value_read(instance, table_id, column_id, row_name, tags, n_tags, thread_id);
@@ -721,7 +721,7 @@ static struct metric **create_dynamic_table_row_metrics(
struct fieldstat_dynamic_instance *instance,
int table_id,
const char *row_name,
- const struct fieldstat_tag tags[],
+ const struct field_tag tags[],
size_t n_tags,
int thread_id,
char *metric_key,
@@ -803,7 +803,7 @@ static int table_row_metric_values_operate(
const char *row_name,
long long values[],
size_t n_values,
- const struct fieldstat_tag tags[],
+ const struct field_tag tags[],
size_t n_tags,
int thread_id,
enum field_op op)
@@ -846,7 +846,7 @@ int fieldstat_dynamic_table_row_metric_values_incrby(
const char *row_name,
long long values[],
size_t n_values,
- const struct fieldstat_tag tags[],
+ const struct field_tag tags[],
size_t n_tags,
int thread_id)
{
@@ -863,7 +863,7 @@ int fieldstat_dynamic_table_row_metric_values_decrby(
const char *row_name,
long long values[],
size_t n_values,
- const struct fieldstat_tag tags[],
+ const struct field_tag tags[],
size_t n_tags,
int thread_id)
{
@@ -880,7 +880,7 @@ int fieldstat_dynamic_table_row_metric_values_set(
const char *row_name,
long long values[],
size_t n_values,
- const struct fieldstat_tag tags[],
+ const struct field_tag tags[],
size_t n_tags,
int thread_id)
{
diff --git a/src/fieldstat_internal.h b/src/fieldstat_internal.h
index 0dc684b..ab1c083 100644
--- a/src/fieldstat_internal.h
+++ b/src/fieldstat_internal.h
@@ -287,9 +287,9 @@ struct metric * get_metric(struct fieldstat_instance *instance, int metric_id);
long long get_metric_unit_val(struct metric *metric,enum field_calc_algo calc_type,int is_refer);
long long read_metric_current_value(struct metric *metric);
int is_valid_field_name(const char* name);
-int is_valid_tags(const struct fieldstat_tag *tags, size_t n_tags);
+int is_valid_tags(const struct field_tag *tags, size_t n_tags);
struct metric ** read_metric_slot(struct fieldstat_instance *instance, int metric_id);
-struct metric * metric_new(enum field_type type, const char *field_name, const struct fieldstat_tag tags[], size_t n_tag);
+struct metric * metric_new(enum field_type type, const char *field_name, const struct field_tag tags[], size_t n_tag);
void metric_free(struct metric *metric);
int file_output(struct fieldstat_instance *instance,long long interval_ms);
struct table_line * read_table_line(struct table_metric *table, int line_id);
@@ -302,7 +302,7 @@ void metric_value_operate(struct metric *metric, enum field_op op, long long val
struct table_metric* table_metric_new(const char *name, const char *column_name[], enum field_type column_type[], size_t n_column);
void table_metric_free(struct table_metric *table);
-struct table_line *table_line_new(const char *name, const struct fieldstat_tag tags[],size_t n_tag);
+struct table_line *table_line_new(const char *name, const struct field_tag tags[],size_t n_tag);
void table_line_free(struct table_line *table_line);
int line_protocol_dynamic_metric_output(struct fieldstat_dynamic_instance *instance);
diff --git a/test/fieldstat_test.cpp b/test/fieldstat_test.cpp
index 95fa11b..4dfec7e 100644
--- a/test/fieldstat_test.cpp
+++ b/test/fieldstat_test.cpp
@@ -80,7 +80,7 @@ static void* dynamic_register(void* arg)
const char * bins_htr = "10,20,30,40,50,60,70,80,90";
const char * bins_sar = "0.1,0.5,0.8,0.9,0.95,0.99";
- struct fieldstat_tag tags[16];
+ struct field_tag tags[16];
tags[0].key = "disable_output_prometheus";
tags[0].value_type = 2;
tags[0].value_str = "yes";
@@ -183,7 +183,7 @@ int test_register_by_fieldstat_type(struct fieldstat_instance *instance)
}
g_counter_id[0] = ret;
- struct fieldstat_tag tag_counter;
+ struct field_tag tag_counter;
tag_counter.value_type = 2;
tag_counter.value_str = "C_one_tag";
tag_counter.key = "C_one_tag_yes";
@@ -196,7 +196,7 @@ int test_register_by_fieldstat_type(struct fieldstat_instance *instance)
}
g_counter_id[1] = ret;
- struct fieldstat_tag tags_counter[3];
+ struct field_tag tags_counter[3];
tags_counter[0].value_type = 2;
tags_counter[0].value_str = "C_tags_0";
tags_counter[0].key = "C_tags_0_yes";
@@ -229,7 +229,7 @@ int test_register_by_fieldstat_type(struct fieldstat_instance *instance)
}
g_gauge_id[0] = ret;
- struct fieldstat_tag tag_gauge;
+ struct field_tag tag_gauge;
tag_gauge.value_type = 2;
tag_gauge.value_str = "G_one_tag";
tag_gauge.key = "G_one_tag_yes";
@@ -242,7 +242,7 @@ int test_register_by_fieldstat_type(struct fieldstat_instance *instance)
}
g_gauge_id[1] = ret;
- struct fieldstat_tag tags_gauge[3];
+ struct field_tag tags_gauge[3];
tags_gauge[0].value_type = 2;
tags_gauge[0].value_str = "G_tags_0";
tags_gauge[0].key = "G_tags_0_yes";
diff --git a/test/src/gtest_dynamic_fieldstat.cpp b/test/src/gtest_dynamic_fieldstat.cpp
index cc5e463..7de7473 100644
--- a/test/src/gtest_dynamic_fieldstat.cpp
+++ b/test/src/gtest_dynamic_fieldstat.cpp
@@ -190,7 +190,7 @@ TEST(FeildStatDynamicAPI, FieldStatDynamicMetricValueIncrby)
{
int ret = 0;
int n_thread = 64;
- struct fieldstat_tag tags[3];
+ struct field_tag tags[3];
tags[0].key = "policy_id";
tags[0].value_int = 1;
@@ -252,7 +252,7 @@ TEST(FeildStatDynamicAPI, FieldStatDynamicMetricValueSet)
{
int ret = 0;
int n_thread = 64;
- struct fieldstat_tag tags[3];
+ struct field_tag tags[3];
tags[0].key = "policy_id";
tags[0].value_int = 1;
@@ -312,7 +312,7 @@ TEST(FeildStatDynamicAPI, FieldStatDynamicMetricValueDecrby)
{
int ret = 0;
int n_thread = 64;
- struct fieldstat_tag tags[3];
+ struct field_tag tags[3];
tags[0].key = "policy_id";
tags[0].value_int = 1;
@@ -373,7 +373,7 @@ TEST(FeildStatDynamicAPI, FieldStatDynamicTableMetricValueIncrby)
{
int ret = 0;
int n_thread = 64;
- struct fieldstat_tag tags[3];
+ struct field_tag tags[3];
tags[0].key = "policy_id";
tags[0].value_int = 1;
@@ -444,7 +444,7 @@ TEST(FeildStatDynamicAPI, FieldStatDynamicTableMetricValueSet)
{
int ret = 0;
int n_thread = 64;
- struct fieldstat_tag tags[3];
+ struct field_tag tags[3];
tags[0].key = "policy_id";
tags[0].value_int = 1;
@@ -515,7 +515,7 @@ TEST(FeildStatDynamicAPI, FieldStatDynamicTableMetricValueDecrby)
{
int ret = 0;
int n_thread = 64;
- struct fieldstat_tag tags[3];
+ struct field_tag tags[3];
tags[0].key = "policy_id";
tags[0].value_int = 1;
@@ -657,7 +657,7 @@ TEST(FeildStatDynamicAPI, FieldStatDynamicOutputLineProtocolOneTag)
int n_thread = 48;
int ret = 0;
struct fieldstat_dynamic_instance *instance = NULL;
- struct fieldstat_tag tags[1];
+ struct field_tag tags[1];
instance = fieldstat_dynamic_instance_new("firewall", n_thread);
const char *compare_one_tag = "{\"fields\":{\"Active_sessions\":11},\"name\":\"Active_sessions\",\"tags\":{\"app_name\":\"firewall\",\"policy_id\":\"1\"}}";
@@ -684,7 +684,7 @@ TEST(FeildStatDynamicAPI, FieldStatDynamicOutputLineProtocolTwoTags)
int n_thread = 48;
int ret = 0;
struct fieldstat_dynamic_instance *instance = NULL;
- struct fieldstat_tag tags[2];
+ struct field_tag tags[2];
instance = fieldstat_dynamic_instance_new("firewall", n_thread);
const char *compare_two_tags = "{\"fields\":{\"Active_sessions\":12},\"name\":\"Active_sessions\",\"tags\":{\"app_name\":\"firewall\",\"policy_id\":\"1\",\"quanlity\":\"0.500000\"}}";
@@ -752,7 +752,7 @@ TEST(FeildStatDynamicAPI, FieldStatDynamicOutputLineProtocolTableMetricOneTag)
enum field_type column_type[] = {FIELD_TYPE_COUNTER, FIELD_TYPE_COUNTER};
unsigned int out_column_ids[2];
int table_id = -1;
- struct fieldstat_tag tags[1];
+ struct field_tag tags[1];
const char *compare_one_tag = "{\"fields\":{\"bytes\":30,\"packages\":30},\"name\":\"security_rule_hits\",\"tags\":{\"app_name\":\"firewall\",\"policy_id\":\"1\",\"table_name\":\"shaping\"}}";
@@ -791,7 +791,7 @@ TEST(FeildStatDynamicAPI, FieldStatDynamicOutputLineProtocolTableMetricTowTags)
enum field_type column_type[] = {FIELD_TYPE_COUNTER, FIELD_TYPE_COUNTER};
unsigned int out_column_ids[2];
int table_id = -1;
- struct fieldstat_tag tags[2];
+ struct field_tag tags[2];
const char *compare_two_tags = "{\"fields\":{\"bytes\":30,\"packages\":30},\"name\":\"security_rule_hits\",\"tags\":{\"app_name\":\"firewall\",\"policy_id\":\"1\",\"quanlity\":\"0.500000\",\"table_name\":\"shaping\"}}";
@@ -1308,7 +1308,7 @@ void _worker_thread_multi_incrby(void *arg)
struct fieldstat_dynamic_instance *instance = para->instance;
int ret = 0;
- struct fieldstat_tag tags[3];
+ struct field_tag tags[3];
int i = 0;
@@ -1445,7 +1445,7 @@ void _worker_thread_multi_decrby(void *arg)
struct fieldstat_dynamic_instance *instance = para->instance;
int ret = 0;
- struct fieldstat_tag tags[3];
+ struct field_tag tags[3];
int i = 0;
@@ -1582,7 +1582,7 @@ void _worker_thread_multi_set(void *arg)
struct fieldstat_dynamic_instance *instance = para->instance;
int ret = 0;
- struct fieldstat_tag tags[3];
+ struct field_tag tags[3];
int i = 0;
@@ -1719,7 +1719,7 @@ void _worker_thread_incrby_multi_metric(void *arg)
struct fieldstat_dynamic_instance *instance = para->instance;
int ret = 0;
- struct fieldstat_tag tags[3];
+ struct field_tag tags[3];
int i = 0;
@@ -1861,7 +1861,7 @@ void _worker_thread_decrby_multi_metric(void *arg)
struct fieldstat_dynamic_instance *instance = para->instance;
int ret = 0;
- struct fieldstat_tag tags[3];
+ struct field_tag tags[3];
int i = 0;
@@ -2005,7 +2005,7 @@ void _worker_thread_set_multi_metric(void *arg)
struct fieldstat_dynamic_instance *instance = para->instance;
int ret = 0;
- struct fieldstat_tag tags[3];
+ struct field_tag tags[3];
int i = 0;
@@ -2150,7 +2150,7 @@ void _worker_thread_multi_incrby_multi_metric(void *arg)
struct fieldstat_dynamic_instance *instance = para->instance;
int ret = 0;
- struct fieldstat_tag tags[3];
+ struct field_tag tags[3];
int i = 0;
@@ -2296,7 +2296,7 @@ void _worker_thread_multi_decrby_multi_metric(void *arg)
struct fieldstat_dynamic_instance *instance = para->instance;
int ret = 0;
- struct fieldstat_tag tags[3];
+ struct field_tag tags[3];
int i = 0;
@@ -2441,7 +2441,7 @@ void _worker_thread_multi_set_multi_metric(void *arg)
struct fieldstat_dynamic_instance *instance = para->instance;
int ret = 0;
- struct fieldstat_tag tags[3];
+ struct field_tag tags[3];
int i = 0;
@@ -2775,7 +2775,7 @@ TEST(FeildStatDynamicAPI, SendLenEqualUDPPayload)
enum field_type column_type[] = {FIELD_TYPE_COUNTER, FIELD_TYPE_COUNTER};
unsigned int out_column_ids[2];
- struct fieldstat_tag tags[4];
+ struct field_tag tags[4];
tags[0].key = "policy_id";
tags[0].value_int = 1;
diff --git a/test/src/gtest_dynamic_fieldstat_output.cpp b/test/src/gtest_dynamic_fieldstat_output.cpp
index 5e86372..4e88de3 100644
--- a/test/src/gtest_dynamic_fieldstat_output.cpp
+++ b/test/src/gtest_dynamic_fieldstat_output.cpp
@@ -30,7 +30,7 @@ void _worker_thread_multi_incrby(void *arg)
struct fieldstat_dynamic_instance *instance = para->instance;
int ret = 0;
- struct fieldstat_tag tags[3];
+ struct field_tag tags[3];
int i = 0;
@@ -126,7 +126,7 @@ void _worker_thread_table_incrby(void *arg)
const char *row_name = "security_rule_hits";
struct fieldstat_dynamic_instance *instance = para->instance;
int ret = 0;
- struct fieldstat_tag tags[14];
+ struct field_tag tags[14];
long long values[20];
diff --git a/test/src/gtest_fieldstat_interface.cpp b/test/src/gtest_fieldstat_interface.cpp
index eb236b7..d2d8eaf 100644
--- a/test/src/gtest_fieldstat_interface.cpp
+++ b/test/src/gtest_fieldstat_interface.cpp
@@ -171,7 +171,7 @@ TEST(FeildStatAPI, FieldStatRegister)
struct fieldstat_instance * instance = NULL;
int metric_id = -1;
struct metric **in_block_metric = NULL;
- struct fieldstat_tag tags[2];
+ struct field_tag tags[2];
tags[0].value_type = 2;
tags[0].value_str = "127.0.0.1";
tags[0].key = "dest_ip";