summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fieldstat.cpp60
-rw-r--r--src/fieldstat_dynamic.cpp26
-rw-r--r--src/fieldstat_internal.h8
-rw-r--r--src/file_output.cpp46
-rw-r--r--src/line_protocol_output.cpp16
-rw-r--r--src/prometheus_output.cpp16
6 files changed, 86 insertions, 86 deletions
diff --git a/src/fieldstat.cpp b/src/fieldstat.cpp
index 8e5cdf8..c26aa5b 100644
--- a/src/fieldstat.cpp
+++ b/src/fieldstat.cpp
@@ -205,7 +205,7 @@ void add_tags_to_metric(const struct field_tag tags[], size_t n_tag, char *tag_k
}
}
-struct metric * metric_new(enum field_type type, const char *field_name, const struct field_tag tags[], size_t n_tag)
+struct metric * metric_new(enum field_metric_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);
@@ -242,8 +242,8 @@ void metric_free(struct metric *metric)
{
metric->table = NULL;
}
- if(metric->field_type == FIELD_TYPE_SUMMARY ||
- metric->field_type == FILED_TYPE_HISTOGRAM)
+ if(metric->field_type == FIELD_METRIC_TYPE_SUMMARY ||
+ metric->field_type == FILED_METRIC_TYPE_DISTRIBUTION)
{
h = &metric->histogram;
if(h->changing != NULL)
@@ -273,14 +273,14 @@ void metric_free(struct metric *metric)
{
switch(metric->field_type)
{
- case FIELD_TYPE_COUNTER:
+ case FIELD_METRIC_TYPE_COUNTER:
if(metric->counter.changing != NULL)
{
free(metric->counter.changing);
metric->counter.changing = NULL;
}
break;
- case FIELD_TYPE_GAUGE:
+ case FIELD_METRIC_TYPE_GAUGE:
if(metric->gauge.changing != NULL)
{
free(metric->gauge.changing);
@@ -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 field_tag tags[], size_t n_tag)
+int fieldstat_register(struct fieldstat_instance *instance, enum field_metric_type type, const char *field_name, const struct field_tag tags[], size_t n_tag)
{
int metric_id = 0;
struct metric *metric = NULL;
@@ -532,11 +532,11 @@ int fieldstat_register(struct fieldstat_instance *instance, enum field_type type
metric->is_atomic_counter = 0;
switch(type)
{
- case FIELD_TYPE_COUNTER:
+ case FIELD_METRIC_TYPE_COUNTER:
memset(&(metric->counter), 0, sizeof(metric->counter));
metric->counter.changing = (struct threadsafe_counter *)calloc(1, sizeof(struct threadsafe_counter));
break;
- case FIELD_TYPE_GAUGE:
+ case FIELD_METRIC_TYPE_GAUGE:
memset(&(metric->gauge), 0, sizeof(metric->gauge));
metric->gauge.changing = (struct threadsafe_counter *)calloc(1, sizeof(struct threadsafe_counter));
break;
@@ -553,10 +553,10 @@ long long get_metric_unit_val(struct metric *metric,enum field_calc_algo calc_ty
long long value = 0;
switch(metric->field_type)
{
- case FIELD_TYPE_COUNTER:
+ case FIELD_METRIC_TYPE_COUNTER:
target = &(metric->counter);
break;
- case FIELD_TYPE_GAUGE:
+ case FIELD_METRIC_TYPE_GAUGE:
target = &(metric->gauge);
break;
default:
@@ -600,10 +600,10 @@ long long read_metric_current_value(struct metric *metric)
long long value = 0;
switch(metric->field_type)
{
- case FIELD_TYPE_COUNTER:
+ case FIELD_METRIC_TYPE_COUNTER:
target = &(metric->counter);
break;
- case FIELD_TYPE_GAUGE:
+ case FIELD_METRIC_TYPE_GAUGE:
target = &(metric->gauge);
break;
default:
@@ -615,7 +615,7 @@ long long read_metric_current_value(struct metric *metric)
else
value = atomic_read(&(target->atomic_changing));
- if(metric->field_type == FIELD_TYPE_GAUGE)
+ if(metric->field_type == FIELD_METRIC_TYPE_GAUGE)
{
value += target->accumulated;
}
@@ -774,7 +774,7 @@ void fieldstat_instance_free(struct fieldstat_instance *instance)
}
-struct table_metric* table_metric_new(const char *name, const char *column_name[], enum field_type column_type[], size_t n_column)
+struct table_metric* table_metric_new(const char *name, const char *column_name[], enum field_metric_type column_type[], size_t n_column)
{
int i = 0;
struct table_metric *table_metric = (struct table_metric *)calloc(1, sizeof(struct table_metric));
@@ -837,7 +837,7 @@ void table_metric_free(struct table_metric *table)
}
- int fieldstat_register_table(struct fieldstat_instance *instance, const char *table_name, const char *column_name[], enum field_type column_type[], size_t n_column)
+ int fieldstat_register_table(struct fieldstat_instance *instance, const char *table_name, const char *column_name[], enum field_metric_type column_type[], size_t n_column)
{
int table_id = 0;
@@ -854,7 +854,7 @@ void table_metric_free(struct table_metric *table)
{
return -1;
}
- if(column_type[i] != FIELD_TYPE_GAUGE && column_type[i] != FIELD_TYPE_COUNTER)
+ if(column_type[i] != FIELD_METRIC_TYPE_GAUGE && column_type[i] != FIELD_METRIC_TYPE_COUNTER)
{
return -1;
}
@@ -997,14 +997,14 @@ void metric_value_operate(struct metric *metric, enum field_op op, long long val
struct stat_unit_t *target = NULL;
switch(metric->field_type)
{
- case FIELD_TYPE_COUNTER:
+ case FIELD_METRIC_TYPE_COUNTER:
target = &(metric->counter);
break;
- case FIELD_TYPE_GAUGE:
+ case FIELD_METRIC_TYPE_GAUGE:
target = &(metric->gauge);
break;
- case FIELD_TYPE_SUMMARY:
- case FILED_TYPE_HISTOGRAM:
+ case FIELD_METRIC_TYPE_SUMMARY:
+ case FILED_METRIC_TYPE_DISTRIBUTION:
hdr_record_value(metric->histogram.changing, (int64_t) value);
return;
default:
@@ -1075,7 +1075,7 @@ int fieldstat_value_decrby(struct fieldstat_instance *instance, int metric_id, l
return ret;
}
-static int parse_histogram_bin_format(const char* format, double **output_bins, enum field_type type)
+static int parse_histogram_bin_format(const char* format, double **output_bins, enum field_metric_type type)
{
char *token=NULL,*sub_token=NULL,*saveptr;
size_t i=0;
@@ -1096,7 +1096,7 @@ static int parse_histogram_bin_format(const char* format, double **output_bins,
if (sub_token == NULL)
break;
ret=sscanf(sub_token,"%lf",bins+i);
- if(type == FIELD_TYPE_SUMMARY)
+ if(type == FIELD_METRIC_TYPE_SUMMARY)
{
if(bins[i]>1.0)
{
@@ -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 field_tag tags[], size_t n_tag,
+static int fieldstat_register_histogram(struct fieldstat_instance *instance, enum field_metric_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;
@@ -1167,10 +1167,10 @@ static int fieldstat_register_histogram(struct fieldstat_instance *instance, enu
switch(type)
{
- case FIELD_TYPE_SUMMARY:
+ case FIELD_METRIC_TYPE_SUMMARY:
atomic_inc(&instance->summary_cnt);
break;
- case FILED_TYPE_HISTOGRAM:
+ case FILED_METRIC_TYPE_DISTRIBUTION:
atomic_inc(&instance->histogram_cnt);
break;
default:
@@ -1184,14 +1184,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 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,
+ return fieldstat_register_histogram(instance, FILED_METRIC_TYPE_DISTRIBUTION, 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 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,
+ return fieldstat_register_histogram(instance, FIELD_METRIC_TYPE_SUMMARY, field_name, tags, n_tag,
bins, lowest_trackable_value, highest_trackable_value, significant_figures, output_window);
}
@@ -1247,17 +1247,17 @@ int fieldstat_set_metric_ratio_para(struct fieldstat_instance *instance, int met
metric_n = get_metric(instance, numerator_metric_id);
metric_d = get_metric(instance, denominator_metric_id);
- if(metric->field_type != FIELD_TYPE_GAUGE && metric->field_type != FIELD_TYPE_COUNTER)
+ if(metric->field_type != FIELD_METRIC_TYPE_GAUGE && metric->field_type != FIELD_METRIC_TYPE_COUNTER)
{
return -1;
}
- if(metric_n->field_type != FIELD_TYPE_GAUGE && metric_n->field_type != FIELD_TYPE_COUNTER)
+ if(metric_n->field_type != FIELD_METRIC_TYPE_GAUGE && metric_n->field_type != FIELD_METRIC_TYPE_COUNTER)
{
return -1;
}
- if(metric_d->field_type != FIELD_TYPE_GAUGE && metric_d->field_type != FIELD_TYPE_COUNTER)
+ if(metric_d->field_type != FIELD_METRIC_TYPE_GAUGE && metric_d->field_type != FIELD_METRIC_TYPE_COUNTER)
{
return -1;
}
diff --git a/src/fieldstat_dynamic.cpp b/src/fieldstat_dynamic.cpp
index 375de17..8861db0 100644
--- a/src/fieldstat_dynamic.cpp
+++ b/src/fieldstat_dynamic.cpp
@@ -251,7 +251,7 @@ void fieldstat_dynamic_instance_start(struct fieldstat_dynamic_instance *instanc
}
}
-int fieldstat_register_dynamic_table(struct fieldstat_dynamic_instance *instance, const char *table_name, const char *column_name[], enum field_type column_type[], size_t n_column, unsigned int out_column_ids[])
+int fieldstat_register_dynamic_table(struct fieldstat_dynamic_instance *instance, const char *table_name, const char *column_name[], enum field_metric_type column_type[], size_t n_column, unsigned int out_column_ids[])
{
int table_id = 0;
int i = 0;
@@ -269,7 +269,7 @@ int fieldstat_register_dynamic_table(struct fieldstat_dynamic_instance *instance
{
return -1;
}
- if(column_type[i] != FIELD_TYPE_GAUGE && column_type[i] != FIELD_TYPE_COUNTER)
+ if(column_type[i] != FIELD_METRIC_TYPE_GAUGE && column_type[i] != FIELD_METRIC_TYPE_COUNTER)
{
return -1;
}
@@ -465,10 +465,10 @@ static struct metric * create_dynamic_table_metric(struct fieldstat_dynamic_inst
metric->is_atomic_counter = 1;
switch(table->column_type[i])
{
- case FIELD_TYPE_COUNTER:
+ case FIELD_METRIC_TYPE_COUNTER:
memset(&(metric->counter), 0, sizeof(metric->counter));
break;
- case FIELD_TYPE_GAUGE:
+ case FIELD_METRIC_TYPE_GAUGE:
memset(&(metric->gauge), 0, sizeof(metric->gauge));
break;
default:
@@ -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 field_tag tags[], size_t n_tags, int thread_id)
+static struct metric * create_dynamic_metric(struct fieldstat_dynamic_instance *instance, enum field_metric_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;
@@ -544,10 +544,10 @@ static struct metric * create_dynamic_metric(struct fieldstat_dynamic_instance *
metric->is_atomic_counter = 1;
switch(metric->field_type)
{
- case FIELD_TYPE_COUNTER:
+ case FIELD_METRIC_TYPE_COUNTER:
memset(&(metric->counter), 0, sizeof(metric->counter));
break;
- case FIELD_TYPE_GAUGE:
+ case FIELD_METRIC_TYPE_GAUGE:
memset(&(metric->gauge), 0, sizeof(metric->gauge));
break;
default:
@@ -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 field_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_metric_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,17 +602,17 @@ 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 field_tag tags[], size_t n_tags, int thread_id)
+int fieldstat_dynamic_metric_value_incrby(struct fieldstat_dynamic_instance *instance, enum field_metric_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 field_tag tags[], size_t n_tags, int thread_id)
+int fieldstat_dynamic_metric_value_set(struct fieldstat_dynamic_instance *instance, enum field_metric_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 field_tag tags[], size_t n_tags, int thread_id)
+int fieldstat_dynamic_metric_value_decrby(struct fieldstat_dynamic_instance *instance, enum field_metric_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);
}
@@ -758,10 +758,10 @@ static struct metric **create_dynamic_table_row_metrics(
metric->is_atomic_counter = 1;
switch(table->column_type[i])
{
- case FIELD_TYPE_COUNTER:
+ case FIELD_METRIC_TYPE_COUNTER:
memset(&(metric->counter), 0, sizeof(metric->counter));
break;
- case FIELD_TYPE_GAUGE:
+ case FIELD_METRIC_TYPE_GAUGE:
memset(&(metric->gauge), 0, sizeof(metric->gauge));
break;
default:
diff --git a/src/fieldstat_internal.h b/src/fieldstat_internal.h
index ab1c083..2e595a2 100644
--- a/src/fieldstat_internal.h
+++ b/src/fieldstat_internal.h
@@ -123,7 +123,7 @@ struct table_metric
{
char *name;
char *column_name[TABLE_COLUMN_SIZE];
- enum field_type column_type[TABLE_COLUMN_SIZE];
+ enum field_metric_type column_type[TABLE_COLUMN_SIZE];
int column_invisible[TABLE_COLUMN_SIZE];
int column_cnt;
@@ -135,7 +135,7 @@ struct table_metric
struct metric
{
char *field_name;
- enum field_type field_type;
+ enum field_metric_type field_type;
size_t n_tag;
char *tag_key[N_TAG_MAX];
char *tag_value[N_TAG_MAX];
@@ -289,7 +289,7 @@ long long read_metric_current_value(struct metric *metric);
int is_valid_field_name(const char* name);
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 field_tag tags[], size_t n_tag);
+struct metric * metric_new(enum field_metric_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);
@@ -299,7 +299,7 @@ void get_current_table_line_cnt(struct fieldstat_instance *instance, int n_table
int startup_udp();
void metric_value_operate(struct metric *metric, enum field_op op, long long value);
-struct table_metric* table_metric_new(const char *name, const char *column_name[], enum field_type column_type[], size_t n_column);
+struct table_metric* table_metric_new(const char *name, const char *column_name[], enum field_metric_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 field_tag tags[],size_t n_tag);
diff --git a/src/file_output.cpp b/src/file_output.cpp
index cd66ec8..ebde407 100644
--- a/src/file_output.cpp
+++ b/src/file_output.cpp
@@ -75,7 +75,7 @@ static int output_file_format_default_type_gauge(struct fieldstat_instance *inst
{
continue;
}
- if(metric->field_type != FIELD_TYPE_GAUGE)
+ if(metric->field_type != FIELD_METRIC_TYPE_GAUGE)
{
continue;
}
@@ -153,7 +153,7 @@ static int output_file_format_default_type_counter(struct fieldstat_instance *in
{
continue;
}
- if(metric->field_type != FIELD_TYPE_COUNTER)
+ if(metric->field_type != FIELD_METRIC_TYPE_COUNTER)
{
continue;
}
@@ -311,7 +311,7 @@ static int build_table_metrics_point(struct fieldstat_instance *instance, struct
}
switch(metric->field_type)
{
- case FIELD_TYPE_GAUGE:
+ case FIELD_METRIC_TYPE_GAUGE:
if(metric->is_ratio == 0)
{
value = get_metric_unit_val(metric, FS_CALC_CURRENT, 0);
@@ -326,7 +326,7 @@ static int build_table_metrics_point(struct fieldstat_instance *instance, struct
}
break;
- case FIELD_TYPE_COUNTER:
+ case FIELD_METRIC_TYPE_COUNTER:
if(metric->is_ratio == 0)
{
value = get_metric_unit_val(metric, FS_CALC_SPEED, 0);
@@ -413,30 +413,30 @@ static int output_file_print_hdr_head(struct metric *metric, char *print_buf, si
double * bins = metric->histogram.bins;
int bins_num = metric->histogram.bins_num;
- if(metric->field_type == FIELD_TYPE_SUMMARY)
+ if(metric->field_type == FIELD_METRIC_TYPE_SUMMARY)
{
snprintf(bin_format, sizeof(bin_format), "%%%d.2lf%%%%", HISTOGRAM_WIDTH-1);
}
- if(metric->field_type == FILED_TYPE_HISTOGRAM)
+ if(metric->field_type == FILED_METRIC_TYPE_DISTRIBUTION)
{
snprintf(bin_format, sizeof(bin_format), "le=%%0.0f");
}
snprintf(str_format, sizeof(str_format), "%%%ds", HISTOGRAM_WIDTH);
- if(metric->field_type == FIELD_TYPE_SUMMARY)
+ if(metric->field_type == FIELD_METRIC_TYPE_SUMMARY)
{
used_len += snprintf(print_buf + used_len, size - used_len, "%-8s\t", "summary");
}
- if(metric->field_type == FILED_TYPE_HISTOGRAM)
+ if(metric->field_type == FILED_METRIC_TYPE_DISTRIBUTION)
{
used_len += snprintf(print_buf + used_len, size - used_len, "%-8s\t", "histogram");
}
for(i = 0;i < bins_num; i++)
{
- if(metric->field_type == FIELD_TYPE_SUMMARY)
+ if(metric->field_type == FIELD_METRIC_TYPE_SUMMARY)
{
snprintf(buff, sizeof(buff), bin_format, bins[i]*100);
}
- if(metric->field_type == FILED_TYPE_HISTOGRAM)
+ if(metric->field_type == FILED_METRIC_TYPE_DISTRIBUTION)
{
snprintf(buff, sizeof(buff), bin_format, bins[i]);
}
@@ -491,11 +491,11 @@ static int output_file_print_hdr_unit(struct metric *metric, char *print_buf, si
for(i = 0; i < bins_num; i++)
{
- if(metric->field_type == FIELD_TYPE_SUMMARY)
+ if(metric->field_type == FIELD_METRIC_TYPE_SUMMARY)
{
value = (long long)hdr_value_at_percentile(h_out, bins[i]*100);
}
- if(metric->field_type == FILED_TYPE_HISTOGRAM)
+ if(metric->field_type == FILED_METRIC_TYPE_DISTRIBUTION)
{
value = hdr_count_le_value(h_out, (long long)bins[i]);
}
@@ -544,8 +544,8 @@ static int output_file_format_default_type_histogram_and_summary(struct fieldsta
{
continue;
}
- if(metric->field_type != FIELD_TYPE_SUMMARY
- && metric->field_type != FILED_TYPE_HISTOGRAM)
+ if(metric->field_type != FIELD_METRIC_TYPE_SUMMARY
+ && metric->field_type != FILED_METRIC_TYPE_DISTRIBUTION)
{
continue;
}
@@ -637,8 +637,8 @@ int output_file_format_json(struct fieldstat_instance *instance, int n_cur_metri
switch(metric->field_type)
{
- case FIELD_TYPE_COUNTER:
- case FIELD_TYPE_GAUGE:
+ case FIELD_METRIC_TYPE_COUNTER:
+ case FIELD_METRIC_TYPE_GAUGE:
tmp_obj = cJSON_CreateObject();
cJSON_AddStringToObject(tmp_obj, "name", metric->field_name);
if(metric->table)
@@ -646,7 +646,7 @@ int output_file_format_json(struct fieldstat_instance *instance, int n_cur_metri
cJSON_AddStringToObject(tmp_obj, "table_name", metric->table->name);
cJSON_AddStringToObject(tmp_obj, "column_name", metric->table->column_name[metric->table_column_id]);
}
- metric->field_type == FIELD_TYPE_COUNTER
+ metric->field_type == FIELD_METRIC_TYPE_COUNTER
?cJSON_AddStringToObject(tmp_obj, "type", "counter")
:cJSON_AddStringToObject(tmp_obj, "type", "gauge");
value = get_metric_unit_val(metric, FS_CALC_CURRENT, 1);
@@ -655,19 +655,19 @@ int output_file_format_json(struct fieldstat_instance *instance, int n_cur_metri
cJSON_AddNumberToObject(tmp_obj, "diff", value);
cJSON_AddItemToArray(metrics_array_obj, tmp_obj);
break;
- case FIELD_TYPE_SUMMARY:
- case FILED_TYPE_HISTOGRAM:
+ case FIELD_METRIC_TYPE_SUMMARY:
+ case FILED_METRIC_TYPE_DISTRIBUTION:
struct hdr_histogram *h_out = read_hdr_unit_output(metric);
for(int j = 0; j < metric->histogram.bins_num; j++)
{
tmp_obj = cJSON_CreateObject();
- if(metric->field_type == FIELD_TYPE_SUMMARY)
+ if(metric->field_type == FIELD_METRIC_TYPE_SUMMARY)
{
value = (long long)hdr_value_at_percentile(h_out, metric->histogram.bins[j]);
cJSON_AddStringToObject(tmp_obj, "type", "summary");
snprintf(tmp_output_name, sizeof(tmp_output_name), "%s.p%.2f", metric->field_name, metric->histogram.bins[j]);
}
- if(metric->field_type == FILED_TYPE_HISTOGRAM)
+ if(metric->field_type == FILED_METRIC_TYPE_DISTRIBUTION)
{
value = hdr_count_le_value(h_out, (long long)metric->histogram.bins[j]);
cJSON_AddStringToObject(tmp_obj, "type", "histogram");
@@ -689,11 +689,11 @@ int output_file_format_json(struct fieldstat_instance *instance, int n_cur_metri
tmp_obj = cJSON_CreateObject();
snprintf(tmp_output_name, sizeof(tmp_output_name), "%s.%s", metric->field_name, extra[j]);
cJSON_AddStringToObject(tmp_obj, "name", tmp_output_name);
- if(metric->field_type == FIELD_TYPE_SUMMARY)
+ if(metric->field_type == FIELD_METRIC_TYPE_SUMMARY)
{
cJSON_AddStringToObject(tmp_obj, "type", "summary");
}
- if(metric->field_type == FILED_TYPE_HISTOGRAM)
+ if(metric->field_type == FILED_METRIC_TYPE_DISTRIBUTION)
{
cJSON_AddStringToObject(tmp_obj, "type", "histogram");
}
diff --git a/src/line_protocol_output.cpp b/src/line_protocol_output.cpp
index 5c01512..36e313b 100644
--- a/src/line_protocol_output.cpp
+++ b/src/line_protocol_output.cpp
@@ -103,10 +103,10 @@ static long long read_single_metric_value(struct metric *metric, int output_type
:is_refer = 1;
switch(metric->field_type)
{
- case FIELD_TYPE_GAUGE:
+ case FIELD_METRIC_TYPE_GAUGE:
value = get_metric_unit_val(metric, FS_CALC_CURRENT, is_refer);
break;
- case FIELD_TYPE_COUNTER:
+ case FIELD_METRIC_TYPE_COUNTER:
value = get_metric_unit_val(metric, FS_CALC_SPEED, is_refer);
break;
default:
@@ -155,12 +155,12 @@ static int add_hdr_field_set(struct metric *metric, struct hdr_histogram *h_out,
{
switch(metric->field_type)
{
- case FIELD_TYPE_SUMMARY:
+ case FIELD_METRIC_TYPE_SUMMARY:
value = (long long)hdr_value_at_percentile(h_out, bins[i]*100);
used_len += snprintf(line_buf + used_len, line_buf_size - used_len,
"P%d=%lld,", (int)(bins[i]*100), value);
break;
- case FILED_TYPE_HISTOGRAM:
+ case FILED_METRIC_TYPE_DISTRIBUTION:
value = hdr_count_le_value(h_out, (long long)bins[i]);
used_len += snprintf(line_buf + used_len, line_buf_size - used_len,
"le%d=%lld,", (int)bins[i], value);
@@ -391,13 +391,13 @@ static void output_line_protocol_single_metric(struct fieldstat_instance *instan
switch(metric->field_type)
{
- case FIELD_TYPE_GAUGE:
- case FIELD_TYPE_COUNTER:
+ case FIELD_METRIC_TYPE_GAUGE:
+ case FIELD_METRIC_TYPE_COUNTER:
used_len = build_single_metric_line_buf(instance->name, instance->output_type,
metric, line_buf, sizeof(line_buf));
break;
- case FIELD_TYPE_SUMMARY:
- case FILED_TYPE_HISTOGRAM:
+ case FIELD_METRIC_TYPE_SUMMARY:
+ case FILED_METRIC_TYPE_DISTRIBUTION:
used_len = build_hdr_metric_line_buf(instance->name, instance->output_type,
metric, line_buf, sizeof(line_buf));
break;
diff --git a/src/prometheus_output.cpp b/src/prometheus_output.cpp
index 1e556d9..6762304 100644
--- a/src/prometheus_output.cpp
+++ b/src/prometheus_output.cpp
@@ -182,12 +182,12 @@ static int prometheus_output_histogram_and_summary(struct metric *metric, char *
int bin_num = metric->histogram.bins_num;
double *bins = metric->histogram.bins;
- if(metric->field_type == FILED_TYPE_HISTOGRAM)
+ if(metric->field_type == FILED_METRIC_TYPE_DISTRIBUTION)
{
output_format = (char *)"%s_bucket{%s,le=\"%0.2f\"} %lld\n";
}
- if(metric->field_type == FIELD_TYPE_SUMMARY)
+ if(metric->field_type == FIELD_METRIC_TYPE_SUMMARY)
{
output_format = (char *)"%s{%s,quantile=\"%0.2f\"} %lld\n";
}
@@ -200,11 +200,11 @@ static int prometheus_output_histogram_and_summary(struct metric *metric, char *
for(i=0;i<bin_num;i++)
{
- if(metric->field_type == FILED_TYPE_HISTOGRAM)
+ if(metric->field_type == FILED_METRIC_TYPE_DISTRIBUTION)
{
value = (long long)hdr_count_le_value(h_out, (long long)bins[i]);
}
- if(metric->field_type == FIELD_TYPE_SUMMARY)
+ if(metric->field_type == FIELD_METRIC_TYPE_SUMMARY)
{
value=(long long)hdr_value_at_percentile(h_out, bins[i]*100);
}
@@ -320,8 +320,8 @@ static int prometheus_get_instance_metric_playload(struct fieldstat_instance *in
switch(metric->field_type)
{
- case FIELD_TYPE_COUNTER:
- case FIELD_TYPE_GAUGE:
+ case FIELD_METRIC_TYPE_COUNTER:
+ case FIELD_METRIC_TYPE_GAUGE:
instance->output_type == 1
?value = get_metric_unit_val(metric, FS_CALC_CURRENT, 0)
:value = get_metric_unit_val(metric, FS_CALC_CURRENT, 1);
@@ -333,8 +333,8 @@ static int prometheus_get_instance_metric_playload(struct fieldstat_instance *in
value
);
break;
- case FIELD_TYPE_SUMMARY:
- case FILED_TYPE_HISTOGRAM:
+ case FIELD_METRIC_TYPE_SUMMARY:
+ case FILED_METRIC_TYPE_DISTRIBUTION:
append_offset += prometheus_output_histogram_and_summary(metric,new_payload + append_offset,
new_payload_size - append_offset, instance_name, metric_name, metric_tags);
break;