]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
Tree wide: Rename "fpcounter" to "counter_fp".
authorFlorian Forster <octo@collectd.org>
Wed, 21 Feb 2024 08:51:24 +0000 (09:51 +0100)
committerFlorian Forster <octo@collectd.org>
Wed, 21 Feb 2024 20:36:31 +0000 (21:36 +0100)
19 files changed:
src/cpu.c
src/daemon/metric.c
src/daemon/metric.h
src/daemon/utils_cache.c
src/daemon/utils_cache.h
src/daemon/utils_cache_test.c
src/disk.c
src/open_telemetry_receiver.cc
src/utils/cmds/putmetric.c
src/utils/common/common.c
src/utils/common/common_test.c
src/utils/format_json/format_json.c
src/utils/format_json/open_telemetry.c
src/utils/format_kairosdb/format_kairosdb.c
src/utils/format_open_telemetry/format_open_telemetry.cc
src/utils/format_stackdriver/format_stackdriver.c
src/utils/format_stackdriver/format_stackdriver_test.c
src/write_prometheus.c
src/write_prometheus_test.c

index c06cc327996320dec765e67b6025bbf9cf3b0006..90a891389e7eb66d91cb2e8ac37a098c55d15f0a 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -488,9 +488,9 @@ static void usage_finalize(usage_t *u) {
       gauge_t ratio = us->rate / cpu_rate;
       value_t v = {0};
       int status = rate_to_value(&v, ratio, &us->to_count,
-                                 METRIC_TYPE_FPCOUNTER, u->time);
+                                 METRIC_TYPE_COUNTER_FP, u->time);
       if (status == 0) {
-        us->count = v.fpcounter;
+        us->count = v.counter_fp;
         us->has_count = true;
       }
 
@@ -504,16 +504,16 @@ static void usage_finalize(usage_t *u) {
     us->count = NAN;
     if (!us->has_rate) {
       /* Ensure that us->to_count is initialized. */
-      rate_to_value(&(value_t){0}, 0.0, &us->to_count, METRIC_TYPE_FPCOUNTER,
+      rate_to_value(&(value_t){0}, 0.0, &us->to_count, METRIC_TYPE_COUNTER_FP,
                     u->time);
       continue;
     }
 
     value_t v = {0};
     int status = rate_to_value(&v, state_ratio[s], &us->to_count,
-                               METRIC_TYPE_FPCOUNTER, u->time);
+                               METRIC_TYPE_COUNTER_FP, u->time);
     if (status == 0) {
-      us->count = v.fpcounter;
+      us->count = v.counter_fp;
       us->has_count = true;
     }
   }
@@ -598,7 +598,7 @@ static void commit_cpu_usage(usage_t *u, size_t cpu_num) {
       .name = "system.cpu.time",
       .help = "Microseconds each logical CPU spent in each state",
       .unit = "s",
-      .type = METRIC_TYPE_FPCOUNTER,
+      .type = METRIC_TYPE_COUNTER_FP,
   };
 
   metric_t m = {0};
@@ -615,13 +615,13 @@ static void commit_cpu_usage(usage_t *u, size_t cpu_num) {
         continue;
       }
       metric_family_append(&fam, label_state, cpu_state_names[state],
-                           (value_t){.fpcounter = usage}, &m);
+                           (value_t){.counter_fp = usage}, &m);
     }
   } else {
     fpcounter_t usage = usage_count(u, cpu_num, STATE_ACTIVE);
     if (!isnan(usage)) {
       metric_family_append(&fam, label_state, cpu_state_names[STATE_ACTIVE],
-                           (value_t){.fpcounter = usage}, &m);
+                           (value_t){.counter_fp = usage}, &m);
     }
   }
 
index eea2fd77967329c44fd3c7c535c1fcac97de8b9f..25b897aca2bc2b3d451b0cd3b86ee00b80d77832 100644 (file)
@@ -58,8 +58,8 @@ int value_marshal_text(strbuf_t *buf, value_t v, metric_type_t type) {
     return strbuf_printf(buf, GAUGE_FORMAT, v.gauge);
   case METRIC_TYPE_COUNTER:
     return strbuf_printf(buf, "%" PRIu64, v.counter);
-  case METRIC_TYPE_FPCOUNTER:
-    return strbuf_printf(buf, GAUGE_FORMAT, v.fpcounter);
+  case METRIC_TYPE_COUNTER_FP:
+    return strbuf_printf(buf, GAUGE_FORMAT, v.counter_fp);
   case METRIC_TYPE_UP_DOWN:
     return strbuf_printf(buf, "%" PRId64, v.up_down);
   case METRIC_TYPE_UP_DOWN_FP:
index 2097dee9191d0655269585876c76d634e84c90ec..d2d78c08f6acc64a07eb820a9f3abd3c1828f96b 100644 (file)
@@ -44,9 +44,9 @@ typedef enum {
   // METRIC_TYPE_COUNTER are monotonically increasing integer counts. The rate
   // of change is meaningful, the absolute value is not.
   METRIC_TYPE_COUNTER = METRIC_ATTR_CUMULATIVE | METRIC_ATTR_MONOTONIC,
-  // METRIC_TYPE_FPCOUNTER are monotonically increasing floating point counts.
+  // METRIC_TYPE_COUNTER_FP are monotonically increasing floating point counts.
   // The rate of change is meaningful, the absolute value is not.
-  METRIC_TYPE_FPCOUNTER =
+  METRIC_TYPE_COUNTER_FP =
       METRIC_ATTR_DOUBLE | METRIC_ATTR_CUMULATIVE | METRIC_ATTR_MONOTONIC,
   // METRIC_TYPE_UP_DOWN are absolute integer metrics that can
   // (meaningfully) be summed up. Examples are filesystem space used and
@@ -60,7 +60,7 @@ typedef enum {
 #define METRIC_TYPE_TO_STRING(t)                                               \
   (t == METRIC_TYPE_GAUGE)        ? "gauge"                                    \
   : (t == METRIC_TYPE_COUNTER)    ? "counter"                                  \
-  : (t == METRIC_TYPE_FPCOUNTER)  ? "fpcounter"                                \
+  : (t == METRIC_TYPE_COUNTER_FP) ? "counter_fp"                               \
   : (t == METRIC_TYPE_UP_DOWN)    ? "up_down"                                  \
   : (t == METRIC_TYPE_UP_DOWN_FP) ? "up_down_fp"                               \
                                   : "unknown"
@@ -78,7 +78,7 @@ typedef double up_down_counter_fp_t;
 union value_u {
   gauge_t gauge;
   counter_t counter;
-  fpcounter_t fpcounter;
+  fpcounter_t counter_fp;
   up_down_counter_t up_down;
   up_down_counter_fp_t up_down_fp;
   // For collectd 5 compatiblity. Treated the same as up_down.
index 51d3ba3342aac19d3cb6ee1e099d1ae60221e180..6b9fe1a6f1b1ca42263a7ffa4cd5790bfd428ff5 100644 (file)
@@ -302,18 +302,18 @@ static int uc_update_rate(metric_t const *m, cache_entry_t *ce) {
     return 0;
   }
 
-  case METRIC_TYPE_FPCOUNTER: {
+  case METRIC_TYPE_COUNTER_FP: {
     // For floating point counters, the logic is slightly different from
     // integer counters. Floating point counters don't have a (meaningful)
     // overflow, and we will always assume a counter reset.
-    if (ce->last_value.fpcounter > m->value.fpcounter) {
+    if (ce->last_value.counter_fp > m->value.counter_fp) {
       // counter reset
       ce->first_time = m->time;
       ce->first_value = m->value;
       ce->values_gauge = NAN;
       return 0;
     }
-    gauge_t diff = m->value.fpcounter - ce->last_value.fpcounter;
+    gauge_t diff = m->value.counter_fp - ce->last_value.counter_fp;
     ce->values_gauge = diff / CDTIME_T_TO_DOUBLE(m->time - ce->last_time);
     return 0;
   }
@@ -480,7 +480,7 @@ int uc_get_rate(metric_t const *m, gauge_t *ret) {
     *ret = m->value.gauge;
     return 0;
   case METRIC_TYPE_COUNTER:
-  case METRIC_TYPE_FPCOUNTER:
+  case METRIC_TYPE_COUNTER_FP:
     break;
   case METRIC_TYPE_UP_DOWN:
     *ret = (gauge_t)m->value.up_down;
index f67e4b8aa9fa3f169ab3b69bfcd1b8a2423d132d..f07605cdd256363f8107d882185bd5747756b94a 100644 (file)
@@ -77,7 +77,7 @@ typedef struct {
 } uc_first_metric_result_t;
 
 /* uc_first_metric returns the first observed metric value and time.
- * For cumulative metrics (METRIC_TYPE_COUNTER and METRIC_TYPE_FPCOUNTER),
+ * For cumulative metrics (METRIC_TYPE_COUNTER and METRIC_TYPE_COUNTER_FP),
  * counter resets and counter overflows will reset the value. */
 uc_first_metric_result_t uc_first_metric(metric_t const *m);
 
index 4d78c742921945c94e046e736c55d688cb5326a7..f5ec1b5bd7d685126a8243ba18c0209637bb5e35 100644 (file)
@@ -87,21 +87,21 @@ DEF_TEST(uc_get_rate) {
           .want = (23. + 18. + 1.) / (110. - 100.),
       },
       {
-          .name = "fpcounter",
-          .first_value = (value_t){.fpcounter = 4.2},
-          .second_value = (value_t){.fpcounter = 10.2},
+          .name = "counter_fp",
+          .first_value = (value_t){.counter_fp = 4.2},
+          .second_value = (value_t){.counter_fp = 10.2},
           .first_time = TIME_T_TO_CDTIME_T(100),
           .second_time = TIME_T_TO_CDTIME_T(110),
-          .type = METRIC_TYPE_FPCOUNTER,
+          .type = METRIC_TYPE_COUNTER_FP,
           .want = (10.2 - 4.2) / (110 - 100),
       },
       {
-          .name = "fpcounter with reset",
-          .first_value = (value_t){.fpcounter = 100000.0},
-          .second_value = (value_t){.fpcounter = 0.2},
+          .name = "counter_fp with reset",
+          .first_value = (value_t){.counter_fp = 100000.0},
+          .second_value = (value_t){.counter_fp = 0.2},
           .first_time = TIME_T_TO_CDTIME_T(100),
           .second_time = TIME_T_TO_CDTIME_T(110),
-          .type = METRIC_TYPE_FPCOUNTER,
+          .type = METRIC_TYPE_COUNTER_FP,
           .want = NAN,
       },
       {
index 21d6688f70d1ac4e87275f08cd5f7da838298ab6..2510df4f61d8a77cb986052230b250392bfa57f7 100644 (file)
@@ -389,7 +389,7 @@ static int disk_read(void) {
       .name = "system.disk.operation_time",
       .help = "Sum of the time each operation took to complete",
       .unit = "s",
-      .type = METRIC_TYPE_FPCOUNTER,
+      .type = METRIC_TYPE_COUNTER_FP,
   };
   metric_family_t fam_merged = {
       .name = "system.disk.merged",
@@ -401,7 +401,7 @@ static int disk_read(void) {
       .name = "system.disk.io_time",
       .help = "Time disk spent activated",
       .unit = "s",
-      .type = METRIC_TYPE_FPCOUNTER,
+      .type = METRIC_TYPE_COUNTER_FP,
   };
   metric_family_t fam_disk_io_weighted_time = {
       .name = "system.disk.weighted_io_time",
@@ -411,7 +411,7 @@ static int disk_read(void) {
               "this field. This can provide an easy measure of both I/O "
               "completion time and the backlog that may be accumulating.",
       .unit = "s",
-      .type = METRIC_TYPE_FPCOUNTER,
+      .type = METRIC_TYPE_COUNTER_FP,
   };
   metric_family_t fam_disk_pending_operations = {
       .name = "system.disk.pending_operations",
@@ -592,10 +592,10 @@ static int disk_read(void) {
     if ((read_time_ns != -1LL) || (write_time_ns != -1LL)) {
       metric_family_append(
           &fam_ops_time, direction_label, read_direction,
-          (value_t){.fpcounter = ((fpcounter_t)read_time_ns) / 1e9}, &m);
+          (value_t){.counter_fp = ((fpcounter_t)read_time_ns) / 1e9}, &m);
       metric_family_append(
           &fam_ops_time, direction_label, write_direction,
-          (value_t){.fpcounter = ((fpcounter_t)write_time_ns) / 1e9}, &m);
+          (value_t){.counter_fp = ((fpcounter_t)write_time_ns) / 1e9}, &m);
     }
     metric_reset(&m);
   }
@@ -721,10 +721,10 @@ static int disk_read(void) {
         devstat_compute_etime(&snap_iter->duration[DEVSTAT_WRITE], NULL);
     if ((read_time_s != 0) || (write_time_s != 0)) {
       metric_family_append(&fam_ops_time, direction_label, read_direction,
-                           (value_t){.fpcounter = (fpcounter_t)read_time_s},
+                           (value_t){.counter_fp = (fpcounter_t)read_time_s},
                            &m);
       metric_family_append(&fam_ops_time, direction_label, write_direction,
-                           (value_t){.fpcounter = (fpcounter_t)write_time_s},
+                           (value_t){.counter_fp = (fpcounter_t)write_time_s},
                            &m);
     }
 
@@ -736,13 +736,13 @@ static int disk_read(void) {
             DSM_QUEUE_LENGTH, &queue_length, DSM_NONE) != 0) {
       WARNING("%s", devstat_errbuf);
     } else {
-      m.value.fpcounter = (fpcounter_t)busy_time;
+      m.value.counter_fp = (fpcounter_t)busy_time;
       metric_family_metric_append(&fam_disk_io_time, m);
 
       m.value.gauge = (gauge_t)utilization;
       metric_family_metric_append(&fam_utilization, m);
 
-      m.value.fpcounter = (fpcounter_t)total_duration_s;
+      m.value.counter_fp = (fpcounter_t)total_duration_s;
       metric_family_metric_append(&fam_disk_io_weighted_time, m);
 
       m.value.gauge = (gauge_t)queue_length;
@@ -899,10 +899,10 @@ static int disk_read(void) {
     if ((read_time_ms != 0) || (write_time_ms != 0)) {
       metric_family_append(
           &fam_ops_time, direction_label, read_direction,
-          (value_t){.fpcounter = ((fpcounter_t)read_time_ms) / 1000}, &m);
+          (value_t){.counter_fp = ((fpcounter_t)read_time_ms) / 1000}, &m);
       metric_family_append(
           &fam_ops_time, direction_label, write_direction,
-          (value_t){.fpcounter = ((fpcounter_t)write_time_ms) / 1000}, &m);
+          (value_t){.counter_fp = ((fpcounter_t)write_time_ms) / 1000}, &m);
     }
 
     if (read_merged != 0 || write_merged != 0) {
@@ -918,12 +918,12 @@ static int disk_read(void) {
     }
 
     if (io_time_ms != 0) {
-      m.value.fpcounter = ((fpcounter_t)io_time_ms) / 1000.0;
+      m.value.counter_fp = ((fpcounter_t)io_time_ms) / 1000.0;
       metric_family_metric_append(&fam_disk_io_time, m);
     }
 
     if (weighted_time_ms != 0) {
-      m.value.fpcounter = ((fpcounter_t)weighted_time_ms) / 1000.0;
+      m.value.counter_fp = ((fpcounter_t)weighted_time_ms) / 1000.0;
       metric_family_metric_append(&fam_disk_io_weighted_time, m);
     }
 
@@ -1012,11 +1012,11 @@ static int disk_read(void) {
 
     if (strncmp(ksp[i]->ks_class, "disk", strlen("disk")) == 0) {
       hrtime_t run_time_ns = kio.rtime;
-      m.value.fpcounter = ((fpcounter_t)run_time_ns) / 1e9;
+      m.value.counter_fp = ((fpcounter_t)run_time_ns) / 1e9;
       metric_family_metric_append(&fam_disk_io_time, m);
 
       hrtime_t weighted_io_time_ns = kio.rlentime;
-      m.value.fpcounter = ((fpcounter_t)weighted_io_time_ns) / 1e9;
+      m.value.counter_fp = ((fpcounter_t)weighted_io_time_ns) / 1e9;
       metric_family_metric_append(&fam_disk_io_weighted_time, m);
 
       uint_t ops_waiting = kio.wcnt;
@@ -1112,10 +1112,10 @@ static int disk_read(void) {
                              _system_configuration.Xfrac;
     metric_family_append(
         &fam_ops_time, direction_label, read_direction,
-        (value_t){.fpcounter = ((fpcounter_t)read_time_ns) / 1e9}, &m);
+        (value_t){.counter_fp = ((fpcounter_t)read_time_ns) / 1e9}, &m);
     metric_family_append(
         &fam_ops_time, direction_label, write_direction,
-        (value_t){.fpcounter = ((fpcounter_t)write_time_ns) / 1e9}, &m);
+        (value_t){.counter_fp = ((fpcounter_t)write_time_ns) / 1e9}, &m);
 
     metric_reset(&m);
   }
@@ -1176,8 +1176,8 @@ static int disk_read(void) {
     metric_family_append(&fam_ops, direction_label, write_direction,
                          (value_t){.counter = drives[i].wxfer}, &m);
 
-    m.value.fpcounter = ((fpcounter_t)drives[i].time_sec) +
-                        ((fpcounter_t)drives[i].time_usec) / 1e6;
+    m.value.counter_fp = ((fpcounter_t)drives[i].time_sec) +
+                         ((fpcounter_t)drives[i].time_usec) / 1e6;
     metric_family_metric_append(&fam_disk_io_time, m);
 
     metric_reset(&m);
index c0dd114fdf57290f205054e9f77feaecf230721b..d82626d0995c8962417307b914e3ca3321d8ec01 100644 (file)
@@ -156,8 +156,8 @@ static grpc::Status unmarshal_data_point(NumberDataPoint dp,
   switch (dp.value_case()) {
   case NumberDataPoint::kAsDouble:
     if (is_cumulative) {
-      fam->type = METRIC_TYPE_FPCOUNTER;
-      m.value.fpcounter = dp.as_double();
+      fam->type = METRIC_TYPE_COUNTER_FP;
+      m.value.counter_fp = dp.as_double();
       break;
     }
     m.value.gauge = dp.as_double();
index 9b07f8723f082158605c53045aa035246addeba2..23020d8984c017d5584040a8a1d85e71811a9b78 100644 (file)
@@ -47,7 +47,7 @@ static int set_option(metric_t *m, char const *key, char const *value,
     } else if (strcasecmp("COUNTER", value) == 0) {
       m->family->type = METRIC_TYPE_COUNTER;
     } else if (strcasecmp("FPCOUNTER", value) == 0) {
-      m->family->type = METRIC_TYPE_FPCOUNTER;
+      m->family->type = METRIC_TYPE_COUNTER_FP;
     } else if (strcasecmp("UP_DOWN_COUNTER", value) == 0) {
       m->family->type = METRIC_TYPE_UP_DOWN;
     } else if (strcasecmp("UP_DOWN_COUNTER_FP", value) == 0) {
@@ -251,7 +251,7 @@ int cmd_format_putmetric(strbuf_t *buf, metric_t const *m) { /* {{{ */
   case METRIC_TYPE_COUNTER:
     strbuf_print(buf, " type=COUNTER");
     break;
-  case METRIC_TYPE_FPCOUNTER:
+  case METRIC_TYPE_COUNTER_FP:
     strbuf_print(buf, " type=FPCOUNTER");
     break;
   case METRIC_TYPE_GAUGE:
index f7b5dbcfaa7c994719d84137c30e79fcabd76269..6010c9724aa77949d302d311fe36c96878193ba8 100644 (file)
@@ -964,8 +964,8 @@ int parse_value(char const *value, value_t *ret_value, metric_type_t type) {
     ret_value->counter = (counter_t)strtoull(value, &endptr, 0);
     break;
 
-  case METRIC_TYPE_FPCOUNTER:
-    ret_value->fpcounter = (fpcounter_t)strtod(value, &endptr);
+  case METRIC_TYPE_COUNTER_FP:
+    ret_value->counter_fp = (fpcounter_t)strtod(value, &endptr);
     break;
 
   case METRIC_TYPE_UP_DOWN:
@@ -1209,7 +1209,7 @@ int rate_to_value(value_t *ret_value, gauge_t rate, /* {{{ */
   /* Counter can't handle negative rates. Reset "last time" to zero, so that
    * the next valid rate will re-initialize the structure. */
   if ((rate < 0.0) &&
-      (type == METRIC_TYPE_COUNTER || type == METRIC_TYPE_FPCOUNTER)) {
+      (type == METRIC_TYPE_COUNTER || type == METRIC_TYPE_COUNTER_FP)) {
     memset(state, 0, sizeof(*state));
     return EINVAL;
   }
@@ -1234,8 +1234,8 @@ int rate_to_value(value_t *ret_value, gauge_t rate, /* {{{ */
       state->last_value.counter = (counter_t)rate;
       state->residual = rate - ((gauge_t)state->last_value.counter);
       break;
-    case METRIC_TYPE_FPCOUNTER:
-      state->last_value.fpcounter = (fpcounter_t)rate;
+    case METRIC_TYPE_COUNTER_FP:
+      state->last_value.counter_fp = (fpcounter_t)rate;
       state->residual = 0;
       break;
     case METRIC_TYPE_UP_DOWN:
@@ -1265,9 +1265,9 @@ int rate_to_value(value_t *ret_value, gauge_t rate, /* {{{ */
     state->residual = delta_gauge - ((gauge_t)delta);
     break;
   }
-  case METRIC_TYPE_FPCOUNTER: {
+  case METRIC_TYPE_COUNTER_FP: {
     fpcounter_t delta = (fpcounter_t)delta_gauge;
-    state->last_value.fpcounter += delta;
+    state->last_value.counter_fp += delta;
     state->residual = 0;
     break;
   }
@@ -1304,12 +1304,12 @@ static int calculate_rate(gauge_t *ret_rate, value_t value, metric_type_t type,
     *ret_rate = ((gauge_t)diff) / ((gauge_t)interval);
     return 0;
   }
-  case METRIC_TYPE_FPCOUNTER: {
-    if (state->last_value.fpcounter > value.fpcounter) {
+  case METRIC_TYPE_COUNTER_FP: {
+    if (state->last_value.counter_fp > value.counter_fp) {
       *ret_rate = NAN;
       return EAGAIN;
     }
-    fpcounter_t diff = value.fpcounter - state->last_value.fpcounter;
+    fpcounter_t diff = value.counter_fp - state->last_value.counter_fp;
     *ret_rate = ((gauge_t)diff) / ((gauge_t)interval);
     return 0;
   }
index 90fe1b090b19ab3bee3987da5ce7065d6b7291f5..ecbf4993953adc947d98f8d69c1aa564862bbffc 100644 (file)
@@ -360,17 +360,17 @@ DEF_TEST(rate_to_value) {
           .want_residual = 0.001,
       },
       {
-          .name = "fpcounter",
+          .name = "counter_fp",
           .rate = 1.234,
           .state =
               {
-                  .last_value = {.fpcounter = 1000},
+                  .last_value = {.counter_fp = 1000},
                   .last_time = TIME_T_TO_CDTIME_T(10),
                   .residual = 0,
               },
-          .type = METRIC_TYPE_FPCOUNTER,
+          .type = METRIC_TYPE_COUNTER_FP,
           .time = TIME_T_TO_CDTIME_T(20),
-          .want = {.fpcounter = 1012.34},
+          .want = {.counter_fp = 1012.34},
       },
       {
           .name = "derive",
@@ -444,9 +444,9 @@ DEF_TEST(rate_to_value) {
       EXPECT_EQ_UINT64(cases[i].want.counter, got.counter);
       EXPECT_EQ_UINT64(cases[i].want.counter, state.last_value.counter);
       break;
-    case METRIC_TYPE_FPCOUNTER:
-      EXPECT_EQ_DOUBLE(cases[i].want.fpcounter, got.fpcounter);
-      EXPECT_EQ_UINT64(cases[i].want.fpcounter, state.last_value.fpcounter);
+    case METRIC_TYPE_COUNTER_FP:
+      EXPECT_EQ_DOUBLE(cases[i].want.counter_fp, got.counter_fp);
+      EXPECT_EQ_UINT64(cases[i].want.counter_fp, state.last_value.counter_fp);
       break;
     case METRIC_TYPE_UP_DOWN:
       EXPECT_EQ_UINT64(cases[i].want.up_down, got.up_down);
@@ -546,27 +546,27 @@ DEF_TEST(value_to_rate) {
           .name = "fpcounter_t init",
           .t0 = 0,
           .t1 = 10,
-          .type = METRIC_TYPE_FPCOUNTER,
-          .v0 = {.fpcounter = 0.},
-          .v1 = {.fpcounter = 10.},
+          .type = METRIC_TYPE_COUNTER_FP,
+          .v0 = {.counter_fp = 0.},
+          .v1 = {.counter_fp = 10.},
           .want_err = EAGAIN,
       },
       {
           .name = "fpcounter_t increase",
           .t0 = 10,
           .t1 = 20,
-          .type = METRIC_TYPE_FPCOUNTER,
-          .v0 = {.fpcounter = 10.},
-          .v1 = {.fpcounter = 50.5},
+          .type = METRIC_TYPE_COUNTER_FP,
+          .v0 = {.counter_fp = 10.},
+          .v1 = {.counter_fp = 50.5},
           .want = (50.5 - 10.) / (20. - 10.),
       },
       {
           .name = "fpcounter_t reset",
           .t0 = 20,
           .t1 = 30,
-          .type = METRIC_TYPE_FPCOUNTER,
-          .v0 = {.fpcounter = 100.0},
-          .v1 = {.fpcounter = 20.0},
+          .type = METRIC_TYPE_COUNTER_FP,
+          .v0 = {.counter_fp = 100.0},
+          .v1 = {.counter_fp = 20.0},
           .want_err = EAGAIN,
       },
   };
index ce30fd6ae96cae9d531bd1cdd538909ee51450a7..17caf90261dbc7ada9eb956a70a7491a940069df 100644 (file)
@@ -163,7 +163,7 @@ static char const *metric_type_to_string(metric_type_t type) {
     return "GAUGE";
   case METRIC_TYPE_COUNTER:
     return "COUNTER";
-  case METRIC_TYPE_FPCOUNTER:
+  case METRIC_TYPE_COUNTER_FP:
     return "FPCOUNTER";
   case METRIC_TYPE_UP_DOWN:
     return "UP_DOWN_COUNTER";
index a90c1284aa3e3d97f8f536e934a629e994e950f3..447d32a1f25002c4029955e9135159adb74fb522 100644 (file)
@@ -100,9 +100,9 @@ static int number_data_point(yajl_gen g, metric_t const *m) {
     CHECK(json_add_string(g, "asInt"));
     CHECK(yajl_gen_integer(g, (long long int)m->value.counter));
     break;
-  case METRIC_TYPE_FPCOUNTER:
+  case METRIC_TYPE_COUNTER_FP:
     CHECK(json_add_string(g, "asDouble"));
-    CHECK(yajl_gen_double(g, m->value.fpcounter));
+    CHECK(yajl_gen_double(g, m->value.counter_fp));
     break;
   case METRIC_TYPE_UP_DOWN:
     CHECK(json_add_string(g, "asInt"));
@@ -179,7 +179,7 @@ static int metric(yajl_gen g, metric_family_t const *fam) {
     CHECK(gauge(g, fam));
     break;
   case METRIC_TYPE_COUNTER:
-  case METRIC_TYPE_FPCOUNTER:
+  case METRIC_TYPE_COUNTER_FP:
   case METRIC_TYPE_UP_DOWN:
   case METRIC_TYPE_UP_DOWN_FP:
     CHECK(json_add_string(g, "sum"));
index f67a245361acce7b5842059e79e6ca3d04d2f975..6a02e1584a382822958241050b3b7c0952bb09bc 100644 (file)
@@ -117,8 +117,8 @@ static int json_add_value(yajl_gen g, metric_t const *m,
   case METRIC_TYPE_COUNTER:
     CHECK(yajl_gen_integer(g, (long long int)m->value.counter));
     return 0;
-  case METRIC_TYPE_FPCOUNTER:
-    CHECK(yajl_gen_double(g, m->value.fpcounter));
+  case METRIC_TYPE_COUNTER_FP:
+    CHECK(yajl_gen_double(g, m->value.counter_fp));
     return 0;
   case METRIC_TYPE_UP_DOWN:
     CHECK(yajl_gen_integer(g, (long long int)m->value.up_down));
index cdda4afce67203c7424284e82e0961192177a6e5..038b50311607ad3709622a5bdd66e4d3a22de356 100644 (file)
@@ -76,8 +76,8 @@ static void metric_to_number_data_point(NumberDataPoint *dp,
   case METRIC_TYPE_UP_DOWN:
     dp->set_as_int((int64_t)m->value.up_down);
     return;
-  case METRIC_TYPE_FPCOUNTER:
-    dp->set_as_double(m->value.fpcounter);
+  case METRIC_TYPE_COUNTER_FP:
+    dp->set_as_double(m->value.counter_fp);
     return;
   case METRIC_TYPE_UP_DOWN_FP:
     dp->set_as_double(m->value.up_down_fp);
@@ -137,7 +137,7 @@ static void add_metric(ScopeMetrics *sm, metric_family_t const *fam) {
     set_gauge(m, fam);
     return;
   case METRIC_TYPE_COUNTER:
-  case METRIC_TYPE_FPCOUNTER:
+  case METRIC_TYPE_COUNTER_FP:
   case METRIC_TYPE_UP_DOWN:
   case METRIC_TYPE_UP_DOWN_FP:
     set_sum(m, fam);
index bc028eaf1dc041d5b88a780434e476f1867cc6df..77d6972a010ff230fb89b36fd71e3ef2fe252b5f 100644 (file)
@@ -155,11 +155,11 @@ static int format_typed_value(yajl_gen gen, metric_t const *m,
     }
     break;
   }
-  case METRIC_TYPE_FPCOUNTER: {
+  case METRIC_TYPE_COUNTER_FP: {
     /* Counter resets are handled in format_time_series(). */
-    assert(m->value.fpcounter >= start_value.fpcounter);
+    assert(m->value.counter_fp >= start_value.counter_fp);
 
-    fpcounter_t diff = m->value.fpcounter - start_value.fpcounter;
+    fpcounter_t diff = m->value.counter_fp - start_value.counter_fp;
     int status = json_string(gen, "doubleValue") || yajl_gen_double(gen, diff);
     if (status != 0) {
       return status;
@@ -207,7 +207,7 @@ static int format_metric_kind(yajl_gen gen, metric_t const *m) {
   case METRIC_TYPE_UP_DOWN_FP:
     return json_string(gen, "GAUGE");
   case METRIC_TYPE_COUNTER:
-  case METRIC_TYPE_FPCOUNTER:
+  case METRIC_TYPE_COUNTER_FP:
     return json_string(gen, "CUMULATIVE");
   case METRIC_TYPE_UNTYPED:
     break;
@@ -226,7 +226,7 @@ static int format_metric_kind(yajl_gen gen, metric_t const *m) {
 static int format_value_type(yajl_gen gen, metric_t const *m) {
   switch (m->family->type) {
   case METRIC_TYPE_GAUGE:
-  case METRIC_TYPE_FPCOUNTER:
+  case METRIC_TYPE_COUNTER_FP:
   case METRIC_TYPE_UP_DOWN_FP:
     return json_string(gen, "DOUBLE");
   case METRIC_TYPE_UP_DOWN:
@@ -407,7 +407,7 @@ static int format_time_series(yajl_gen gen, metric_t const *m,
     }
     break;
   case METRIC_TYPE_COUNTER:
-  case METRIC_TYPE_FPCOUNTER:
+  case METRIC_TYPE_COUNTER_FP:
     // for cumulative metrics the interval must not be zero.
     if (start.time == m->time) {
       return EAGAIN;
index b39913a5116bb9be8488b148351b49c5d88955f9..2bb1a98d5e0f35afa2d8ca31d13d625e34ef0373 100644 (file)
@@ -50,7 +50,7 @@ DEF_TEST(sd_format_metric_descriptor) {
       },
       {
           .name = "fpcounter_metric",
-          .type = METRIC_TYPE_FPCOUNTER,
+          .type = METRIC_TYPE_COUNTER_FP,
           .want = "{\"type\":\"custom.googleapis.com/collectd/"
                   "fpcounter_metric\",\"metricKind\":\"CUMULATIVE\","
                   "\"valueType\":\"DOUBLE\",\"labels\":[]}",
index 831cd660e807645c7b7cf2a195608293b725cde2..bf4c380007f6186d8000fb1db45cf7f7acecec97 100644 (file)
@@ -296,7 +296,7 @@ static void format_metric_family(strbuf_t *buf,
     type = "gauge";
     break;
   case METRIC_TYPE_COUNTER:
-  case METRIC_TYPE_FPCOUNTER:
+  case METRIC_TYPE_COUNTER_FP:
     type = "counter";
     break;
   case METRIC_TYPE_UNTYPED:
index 67556c3f7c5829c1a311f5fdaeb02f8387f38c98..e59cd3076232c3ea3ebae5fea2840a690f7ca37d 100644 (file)
@@ -269,14 +269,14 @@ DEF_TEST(format_metric_family) {
           // clang-format on
       },
       {
-          .name = "METRIC_TYPE_FPCOUNTER",
+          .name = "METRIC_TYPE_COUNTER_FP",
           .pfam =
               {
                   .name = "unit_test",
-                  .type = METRIC_TYPE_FPCOUNTER,
+                  .type = METRIC_TYPE_COUNTER_FP,
                   .metrics =
                       (prometheus_metric_t[]){
-                          {.value.fpcounter = 42.0},
+                          {.value.counter_fp = 42.0},
                       },
                   .metrics_num = 1,
               },