Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
* strip newline off the packet to work better with statsd 0.5.0 which…
Browse files Browse the repository at this point in the history
… records it as a "bad line" - see comments for details
  • Loading branch information
Jos Boumans committed Aug 29, 2012
1 parent 60b6bb3 commit 127678d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/vmod_statsd.c
Expand Up @@ -200,7 +200,14 @@ _send_to_statsd( struct vmod_priv *priv, const char *key, const char *val ) {
strncat( stat, key, strlen(key) + 1 );
strncat( stat, cfg->suffix, strlen(cfg->suffix) + 1 );
strncat( stat, val, strlen(val) + 1 );
strncat( stat, "\n", 1 );

// Newer versions of statsd allow multiple metrics in a single packet, delimited
// by newlines. That unfortunately means that if we end our message with a new
// line, statsd will interpret this as an empty second metric and log a 'bad line'.
// This is true in at least version 0.5.0 and to avoid that, we don't send the
// newline. Makes debugging using nc -klu 8125 a bit more tricky, but works with
// modern statsds.
//strncat( stat, "\n", 1 );

_DEBUG && fprintf( stderr, "send: %s:%s %s\n", cfg->host, cfg->port, stat );

Expand Down

0 comments on commit 127678d

Please sign in to comment.