From 3f2709d4d27923f239a0828f20af3d87748ff150 Mon Sep 17 00:00:00 2001 From: Elene Margalitadze <68648605+elene-margalit@users.noreply.github.com> Date: Mon, 17 Aug 2020 17:35:56 +0200 Subject: [PATCH] Revert "Integrate distribution metrics into collectd core: add new distribution_t value to metric_type_t enum, add distribution_t* to the value_t pointer, modify function metric_reset to call distribution_destroy when appropriate, add according documentation to metric.h. Modify metric_list_clone to call distribution_clone when appropriate." This reverts commit ce53eb79ae455131e28c1869a28150e0c48cfad3. --- src/daemon/metric.c | 19 ++++--------------- src/daemon/metric.h | 11 +---------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/src/daemon/metric.c b/src/daemon/metric.c index 2196b36ff..16052be61 100644 --- a/src/daemon/metric.c +++ b/src/daemon/metric.c @@ -26,6 +26,7 @@ **/ #include "collectd.h" + #include "metric.h" #include "plugin.h" @@ -205,10 +206,6 @@ int metric_reset(metric_t *m) { label_set_reset(&m->label); meta_data_destroy(m->meta); - if(m->family->type == METRIC_TYPE_DISTRIBUTION) { - distribution_destroy(m->value.distribution); - } - memset(m, 0, sizeof(*m)); return 0; @@ -348,19 +345,12 @@ static int metric_list_clone(metric_list_t *dest, metric_list_t src, } for (size_t i = 0; i < src.num; i++) { - - ret.ptr[i] = (metric_t){ + ret.ptr[i] = (metric_t){ .family = fam, + .value = src.ptr[i].value, .time = src.ptr[i].time, .interval = src.ptr[i].interval, - }; - - if(src.ptr[i].family->type == METRIC_TYPE_DISTRIBUTION) { - ret.ptr[i].value.distribution = distribution_clone(src.ptr[i].value.distribution); - } - else { - ret.ptr[i].value = src.ptr[i].value; - } + }; int status = label_set_clone(&ret.ptr[i].label, src.ptr[i].label); if (status != 0) { @@ -633,4 +623,3 @@ metric_t *metric_parse_identity(char const *buf) { return fam->metric.ptr; } - diff --git a/src/daemon/metric.h b/src/daemon/metric.h index 6af52562f..0419304ed 100644 --- a/src/daemon/metric.h +++ b/src/daemon/metric.h @@ -31,7 +31,6 @@ #include "utils/metadata/meta_data.h" #include "utils/strbuf/strbuf.h" #include "utils_time.h" -#include "distribution.h" #define VALUE_TYPE_GAUGE 1 #define VALUE_TYPE_DERIVE 2 @@ -40,7 +39,6 @@ typedef enum { METRIC_TYPE_COUNTER = 0, METRIC_TYPE_GAUGE = 1, METRIC_TYPE_UNTYPED = 2, - METRIC_TYPE_DISTRIBUTION = 3, } metric_type_t; typedef uint64_t counter_t; @@ -51,7 +49,6 @@ union value_u { counter_t counter; gauge_t gauge; derive_t derive; - distribution_t *distribution; }; typedef union value_u value_t; @@ -128,7 +125,7 @@ int metric_label_set(metric_t *m, char const *name, char const *value); char const *metric_label_get(metric_t const *m, char const *name); /* metric_reset frees all labels and meta data stored in the metric and resets - * the metric to zero. If the metric is a distribution metric, the function frees the according distribution.*/ + * the metric to zero. */ int metric_reset(metric_t *m); /* metric_list_t is an unordered list of metrics. */ @@ -178,10 +175,4 @@ void metric_family_free(metric_family_t *fam); * metric_family_free(). */ metric_family_t *metric_family_clone(metric_family_t const *fam); -/*The static function metric_list_clone creates a clone of the argument metric_list_t src. For each metric_t element - *in the src list it checks if its value is a distribution metric and if yes, calls the distribution_clone function - *for the value and saves the pointer to the returned distribution_t clone into the metric_list_t dest. If - *the value is not a distribution_t, it simply sets the value of the element in the destination list to the value - *of the element in the source list. */ - #endif -- 2.47.2