From: Svetlana Shmidt Date: Mon, 14 Sep 2020 11:11:04 +0000 (+0000) Subject: add new typed_value type X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e71ed833c0fe2f055e27ea2fffd51ee98cb54b7;p=thirdparty%2Fcollectd.git add new typed_value type --- diff --git a/src/daemon/metric.c b/src/daemon/metric.c index e604655fb..0ac4660af 100644 --- a/src/daemon/metric.c +++ b/src/daemon/metric.c @@ -31,6 +31,17 @@ #include "metric.h" #include "plugin.h" +typed_value_t typed_value_clone(typed_value_t val) { + typed_value_t copy = { + .value = val.value, + .type = val.type, + }; + if (val.type == METRIC_TYPE_DISTRIBUTION) { + copy.value.distribution = distribution_clone(val.value.distribution); + } + return copy; +} + /* Label names must match the regex `[a-zA-Z_][a-zA-Z0-9_]*`. Label names * beginning with __ are reserved for internal use. * diff --git a/src/daemon/metric.h b/src/daemon/metric.h index 3167cd9b0..0c934e8f8 100644 --- a/src/daemon/metric.h +++ b/src/daemon/metric.h @@ -56,6 +56,13 @@ union value_u { }; typedef union value_u value_t; +typedef struct { + value_t value; + metric_type_t type; +} typed_value_t; + +typed_value_t typed_value_clone(typed_value_t val); + /* value_marshal_text prints a text representation of v to buf. */ int value_marshal_text(strbuf_t *buf, value_t v, metric_type_t type);