statsd extracts and ignores datadog statsd tags; fixes #3978
Costa Tsaousis (ktsaou) committed
Jul 18, 2018 at 21:54 UTC
2fa7e419e23bddb6544e56778bae1e0cc57e9437
1 file changed
+13
-5
src/statsd.c
+13
-5
@@ -603,8 +603,10 @@ static inline void statsd_process_set(STATSD_METRIC *m, const char *value) {
603
// --------------------------------------------------------------------------------------------------------------------
604
// statsd parsing
605
606
-static void statsd_process_metric(const char *name, const char *value, const char *type, const char *sampling) {
607
- debug(D_STATSD, "STATSD: raw metric '%s', value '%s', type '%s', rate '%s'", name?name:"(null)", value?value:"(null)", type?type:"(null)", sampling?sampling:"(null)");
606
+static void statsd_process_metric(const char *name, const char *value, const char *type, const char *sampling, const char *tags) {
607
+ (void)tags;
608
+
609
+ debug(D_STATSD, "STATSD: raw metric '%s', value '%s', type '%s', sampling '%s', tags '%s'", name?name:"(null)", value?value:"(null)", type?type:"(null)", sampling?sampling:"(null)", tags?tags:"(null)");
610
611
if(unlikely(!name || !*name)) return;
612
if(unlikely(!type || !*type)) type = "m";
@@ -688,8 +690,8 @@ static inline size_t statsd_process(char *buffer, size_t size, int require_newli
690
691
const char *s = buffer;
692
while(*s) {
691
- const char *name = NULL, *value = NULL, *type = NULL, *sampling = NULL;
692
- char *name_end = NULL, *value_end = NULL, *type_end = NULL, *sampling_end = NULL;
693
+ const char *name = NULL, *value = NULL, *type = NULL, *sampling = NULL, *tags = NULL;
694
+ char *name_end = NULL, *value_end = NULL, *type_end = NULL, *sampling_end = NULL, *tags_end = NULL;
695
696
s = name_end = (char *)statsd_parse_skip_up_to(name = s, ':', '|');
697
if(name == name_end) {
@@ -704,10 +706,15 @@ static inline size_t statsd_process(char *buffer, size_t size, int require_newli
706
s = type_end = (char *) statsd_parse_skip_up_to(type = ++s, '|', '@');
707
708
if(likely(*s == '|' || *s == '@')) {
707
- s = sampling_end = (char *) statsd_parse_skip_up_to(sampling = ++s, '\r', '\n');
709
+ s = sampling_end = (char *) statsd_parse_skip_up_to(sampling = ++s, '|', '#');
710
if(*sampling == '@') sampling++;
711
}
712
713
+ if(likely(*s == '|' || *s == '#')) {
714
+ s = tags_end = (char *) statsd_parse_skip_up_to(tags = ++s, '|', '|');
715
+ if(*tags == '@') tags++;
716
+ }
717
+
718
// skip everything until the end of the line
719
while(*s && *s != '\n') s++;
720
@@ -725,6 +732,7 @@ static inline size_t statsd_process(char *buffer, size_t size, int require_newli
732
, statsd_parse_field_trim(value, value_end)
733
, statsd_parse_field_trim(type, type_end)
734
, statsd_parse_field_trim(sampling, sampling_end)
735
+ , statsd_parse_field_trim(tags, tags_end)
736
);
737
}
738