]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
src/daemon/plugin.c: Log a debug message when a metric family has no metrics. 4257/head
authorFlorian Forster <octo@collectd.org>
Fri, 26 Jan 2024 13:37:56 +0000 (14:37 +0100)
committerFlorian Forster <octo@collectd.org>
Mon, 29 Jan 2024 10:17:10 +0000 (11:17 +0100)
src/daemon/plugin.c
src/utils/format_json/format_json_test.c

index 7ed260503da13999c3e7418f5ce993e172c2ef47..0ab5999dbbd146785e479df3a37385148b4e8783 100644 (file)
@@ -2105,6 +2105,9 @@ EXPORT int plugin_dispatch_metric_family(metric_family_t const *fam) {
     return EINVAL;
   }
   if (fam->metric.num == 0) {
+    DEBUG("plugin_dispatch_metric_family: Metric family \"%s\" contains zero "
+          "metrics.",
+          fam->name);
     return 0;
   }
 
index 528be87c0bfdb3688675beeece4e48b8889a1bbe..9f73a00a7a28cfaeea1a990cda4911f966e0de01 100644 (file)
@@ -136,7 +136,7 @@ static int expect_json_labels(char *json, label_pair_t *labels,
 
 DEF_TEST(notification) {
   label_pair_t labels[] = {
-      {"summary", "this is a message"},
+      {"summary", "this is a \"message\""},
       {"alertname", "collectd_unit_test"},
       {"instance", "example.com"},
       {"service", "collectd"},
@@ -144,19 +144,21 @@ DEF_TEST(notification) {
   };
 
   /* 1448284606.125 ^= 1555083754651779072 */
-  notification_t n = {NOTIF_WARNING,
-                      1555083754651779072ULL,
-                      "this is a message",
-                      "example.com",
-                      "unit",
-                      "",
-                      "test",
-                      "case",
-                      NULL};
+  notification_t n = {
+      .severity = NOTIF_WARNING,
+      .time = 1555083754651779072ULL,
+      .message = "this is a \"message\"",
+      .host = "example.com",
+      .plugin = "unit",
+      .plugin_instance = "",
+      .type = "test",
+      .type_instance = "case",
+      .meta = NULL,
+  };
 
   char got[1024];
   CHECK_ZERO(format_json_notification(got, sizeof(got), &n));
-  // printf ("got = \"%s\";\n", got);
+  printf("got = \"%s\";\n", got);
 
   return expect_json_labels(got, labels, STATIC_ARRAY_SIZE(labels));
 }