diff options
author | Vladimir Kobal <vlad@prokk.net> | 2020-01-09 12:51:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-09 12:51:41 +0200 |
commit | 0fba85e2c20add69546cefbf37bb2033d2d1e052 (patch) | |
tree | dd124104fb54f99ef2ddca7e92e946d2d7f7aa31 /libnetdata | |
parent | 37edc6898b453b80806f07264cc94acf04bdd39e (diff) |
Send host labels via exporting connectors (#7554)
* Add labels to the JSON exporting connector
* Add labels to the Graphite exporting connector
* Add labels to the OpenTSDB telnet exporting connector
* Add labels to the OpenTSDB HTTP exporting connector
* Replace control characters in JSON strings
* Add unit tests
Diffstat (limited to 'libnetdata')
-rw-r--r-- | libnetdata/inlined.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libnetdata/inlined.h b/libnetdata/inlined.h index 330b65648e..6f236b8f47 100644 --- a/libnetdata/inlined.h +++ b/libnetdata/inlined.h @@ -246,12 +246,18 @@ static inline char *strncpyz(char *dst, const char *src, size_t n) { return p; } -static inline void escape_json_string(char *dst, char *src, size_t len) { +static inline void sanitize_json_string(char *dst, char *src, size_t len) { while (*src != '\0' && len > 1) { if (*src == '\\' || *src == '\"' || *src < 0x1F) { - *dst++ = '\\'; - *dst++ = *src++; - len -= 2; + if (*src < 0x1F) { + *dst++ = '_'; + src++; + len--; + } else { + *dst++ = '\\'; + *dst++ = *src++; + len -= 2; + } } else { *dst++ = *src++; len--; |