]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
add new typed_value type
authorSvetlana Shmidt <sshmidt@google.com>
Mon, 14 Sep 2020 11:11:04 +0000 (11:11 +0000)
committerSvetlana Shmidt <sshmidt@google.com>
Mon, 14 Sep 2020 11:11:04 +0000 (11:11 +0000)
src/daemon/metric.c
src/daemon/metric.h

index e604655fb512d34900e226c85138c42021662187..0ac4660af4a328c4377757c9b58f683b3008454a 100644 (file)
 #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.
  *
index 3167cd9b014bc4f96febb2ab1c1be92735b7ae65..0c934e8f8974155bb4233b0798cae486d7e6bd26 100644 (file)
@@ -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);