]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
format_json, format_kairosdb: Don't enable beatification of JSON.
authorFlorian Forster <octo@google.com>
Thu, 9 Jul 2020 10:29:15 +0000 (12:29 +0200)
committerFlorian Forster <octo@google.com>
Wed, 29 Jul 2020 11:40:54 +0000 (13:40 +0200)
The code depends on the last character in the buffer being ']'. If
"beautification" is enabled, it will add a newline at the end, which
breaks the "append" mechanic.

src/utils/format_json/format_json.c
src/utils/format_kairosdb/format_kairosdb.c

index 5958b12d79d319f828b89c866e6574b94e8b365c..ceecc745ae0a50e4e67bd6b950623fbb03d343f3 100644 (file)
@@ -224,16 +224,11 @@ int format_json_metric_family(strbuf_t *buf, metric_family_t const *fam,
   if (g == NULL)
     return -1;
 #if COLLECT_DEBUG
-  yajl_gen_config(g, yajl_gen_beautify, 1);
   yajl_gen_config(g, yajl_gen_validate_utf8, 1);
 #endif
 
 #else /* !HAVE_YAJL_V2 */
   yajl_gen_config conf = {0};
-#if COLLECT_DEBUG
-  conf.beautify = 1;
-  conf.indentString = "  ";
-#endif
   yajl_gen g = yajl_gen_alloc(&conf, NULL);
   if (g == NULL)
     return -1;
index 6b7eb2ce19d4ff4a9238b789eeb04349e39d9468..68d17fd42514457508c9a2e98193fb1b59e430bf 100644 (file)
@@ -76,7 +76,7 @@ static int json_add_string(yajl_gen g, char const *str) /* {{{ */
   do {                                                                         \
     int status = (f);                                                          \
     if (status != 0) {                                                         \
-      ERROR("format_kairosdb: %s = %d", #f, status);                           \
+      ERROR("format_kairosdb: %s failed with status %d", #f, status);                           \
       return status;                                                           \
     }                                                                          \
   } while (0)
@@ -176,16 +176,11 @@ int format_kairosdb_metric_family(strbuf_t *buf, metric_family_t const *fam,
   if (g == NULL)
     return ENOMEM;
 #if COLLECT_DEBUG
-  yajl_gen_config(g, yajl_gen_beautify, 1);
   yajl_gen_config(g, yajl_gen_validate_utf8, 1);
 #endif
 
 #else /* !HAVE_YAJL_V2 */
   yajl_gen_config conf = {0};
-#if COLLECT_DEBUG
-  conf.beautify = 1;
-  conf.indentString = "  ";
-#endif
   yajl_gen g = yajl_gen_alloc(&conf, NULL);
   if (g == NULL)
     return ENOMEM;