]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
format_json: More cleanups.
authorFlorian Forster <octo@google.com>
Fri, 17 Jul 2020 10:43:13 +0000 (12:43 +0200)
committerFlorian Forster <octo@google.com>
Wed, 29 Jul 2020 11:40:03 +0000 (13:40 +0200)
*   Struct "metric_t": unnecessary fields "type", "plugin", "ds" have
    been removed. The field "value_ds_type" has been renamed to
    "value_type".
*   The reference counted, multiple instance "meta_data_list_head_t" type
    has been removed. Manually doing the reference counting all over the
    place is error prone and it seems like premature optimization.
*   The "<type>_destroy" functions must handle NULL gracefully. Removed
    NULL-checks around their invocation to improve readability.

# Conflicts:
# src/daemon/metrics_list_test.c

src/utils/format_json/format_json.c

index 32f35e8730d5ae77b7a6123ebb2ac4436221a33e..d3f97f190768a85015b7b85e14915ff530f5f6f2 100644 (file)
@@ -421,7 +421,7 @@ int format_json_metric(char *buffer_p, size_t *ret_buffer_fill, /* {{{ */
      will be replaced by a [ */
   BUFFER_ADD(",{");
   BUFFER_ADD_KEYVAL("name", metric_p->identity->name);
-  if (metric_p->value_ds_type == DS_TYPE_GAUGE) {
+  if (metric_p->value_type == DS_TYPE_GAUGE) {
     if (isfinite(metric_p->value.gauge))
       BUFFER_ADD(JSON_GAUGE_FORMAT, metric_p->value.gauge);
     else
@@ -439,14 +439,14 @@ int format_json_metric(char *buffer_p, size_t *ret_buffer_fill, /* {{{ */
       BUFFER_ADD(JSON_GAUGE_FORMAT, rate);
     else
       BUFFER_ADD("null");
-  } else if (metric_p->value_ds_type == DS_TYPE_COUNTER)
+  } else if (metric_p->value_type == DS_TYPE_COUNTER)
     BUFFER_ADD("%" PRIu64, (uint64_t)metric_p->value.counter);
-  else if (metric_p->value_ds_type == DS_TYPE_DERIVE)
+  else if (metric_p->value_type == DS_TYPE_DERIVE)
     BUFFER_ADD("%" PRIi64, metric_p->value.derive);
-  else if (metric_p->value_ds_type == DS_TYPE_ABSOLUTE)
+  else if (metric_p->value_type == DS_TYPE_ABSOLUTE)
     BUFFER_ADD("%" PRIu64, metric_p->value.absolute);
   else {
-    ERROR("format_json: Unknown data source type: %i", metric_p->value_ds_type);
+    ERROR("format_json: Unknown data source type: %i", metric_p->value_type);
     buffer_p[*ret_buffer_fill] = '0';
     return -1;
   }
@@ -456,7 +456,7 @@ int format_json_metric(char *buffer_p, size_t *ret_buffer_fill, /* {{{ */
   BUFFER_ADD_KEYVAL("plugin", metric_p->plugin);
   BUFFER_ADD_KEYVAL("type", metric_p->type);
   BUFFER_ADD_KEYVAL("dsname", metric_p->ds->name);
-  BUFFER_ADD_KEYVAL("dstype", DS_TYPE_TO_STRING(metric_p->value_ds_type));
+  BUFFER_ADD_KEYVAL("dstype", DS_TYPE_TO_STRING(metric_p->value_type));
 
   if (metric_p->identity->root_p != NULL) {
     c_avl_iterator_t *iter_p = c_avl_get_iterator(metric_p->identity->root_p);