Skip to content

Commit

Permalink
Increments bad_lines_seen when sampleRate bit does not match regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Reed committed Aug 27, 2012
1 parent 4bd7597 commit 6762a41
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,15 @@ config.configFile(process.argv[2], function (config, oldConfig) {
} else if (fields[1].trim() == "g") {
gauges[key] = Number(fields[0] || 0);
} else {
if (fields[2] && fields[2].match(/^@([\d\.]+)/)) {
sampleRate = Number(fields[2].match(/^@([\d\.]+)/)[1]);
if (fields[2]) {
if (fields[2].match(/^@([\d\.]+)/)) {
sampleRate = Number(fields[2].match(/^@([\d\.]+)/)[1]);
} else {
l.log('Bad line: ' + fields + ' in msg "' + metrics[midx] +'"; has invalid sample rate');
counters["statsd.bad_lines_seen"]++;
stats['messages']['bad_lines_seen']++;
continue;
}
}
if (! counters[key]) {
counters[key] = 0;
Expand Down

0 comments on commit 6762a41

Please sign in to comment.