show sample of backend received data
Costa Tsaousis (ktsaou) committed
Dec 24, 2016 at 20:24 UTC
152a18c44a27b29812dff635b81c55ba25639cbe
1 file changed
+24
-2
src/backends.c
+24
-2
@@ -95,13 +95,35 @@ static inline int format_dimension_stored_opentsdb_telnet(BUFFER *b, const char
95
}
96
97
static inline int process_graphite_response(BUFFER *b) {
98
- info("Received %zu bytes from graphite backend. Ignoring them.", buffer_strlen(b));
98
+ char sample[1024];
99
+ const char *s = buffer_tostring(b);
100
+ char *d = sample, *e = &sample[sizeof(sample) - 1];
101
+
102
+ for(; *s && d < e ;s++) {
103
+ char c = *s;
104
+ if(unlikely(!isprint(c))) c = ' ';
105
+ *d++ = c;
106
+ }
107
+ *d = '\0';
108
+
109
+ info("Received %zu bytes from graphite backend. Ignoring them. Sample: '%s'", buffer_strlen(b), sample);
110
buffer_flush(b);
111
return 0;
112
}
113
114
static inline int process_opentsdb_response(BUFFER *b) {
104
- info("Received %zu bytes from opentsdb backend. Ignoring them.", buffer_strlen(b));
115
+ char sample[1024];
116
+ const char *s = buffer_tostring(b);
117
+ char *d = sample, *e = &sample[sizeof(sample) - 1];
118
+
119
+ for(; *s && d < e ;s++) {
120
+ char c = *s;
121
+ if(unlikely(!isprint(c))) c = ' ';
122
+ *d++ = c;
123
+ }
124
+ *d = '\0';
125
+
126
+ info("Received %zu bytes from opentsdb backend. Ignoring them. Sample: '%s'", buffer_strlen(b), sample);
127
buffer_flush(b);
128
return 0;
129
}