]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
add create_typed_value function
authorSvetlana Shmidt <sshmidt@google.com>
Tue, 15 Sep 2020 07:24:27 +0000 (07:24 +0000)
committerSvetlana Shmidt <sshmidt@google.com>
Tue, 15 Sep 2020 07:24:27 +0000 (07:24 +0000)
src/daemon/metric.c
src/daemon/metric.h

index 0ac4660af4a328c4377757c9b58f683b3008454a..0b14ec2925b2e698258ac05088c7e4e2ef6d66c4 100644 (file)
@@ -42,6 +42,17 @@ typed_value_t typed_value_clone(typed_value_t val) {
   return copy;
 }
 
+typed_value_t create_typed_value(value_t val, metric_type_t type) {
+  typed_value_t tval = {
+      .value = val,
+      .type = type,
+  };
+  if (type == METRIC_TYPE_DISTRIBUTION) {
+    tval.value.distribution = distribution_clone(val.distribution);
+  }
+  return tval;
+}
+
 /* Label names must match the regex `[a-zA-Z_][a-zA-Z0-9_]*`. Label names
  * beginning with __ are reserved for internal use.
  *
index 0c934e8f8974155bb4233b0798cae486d7e6bd26..22cb82923d26910aa67c570210282fa033375e30 100644 (file)
@@ -63,6 +63,8 @@ typedef struct {
 
 typed_value_t typed_value_clone(typed_value_t val);
 
+typed_value_t create_typed_value(value_t val, metric_type_t type);
+
 /* 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);