Permalink
Browse files

Increments bad_lines_seen when sampleRate bit does not match regex

  • Loading branch information...
1 parent 4bd7597 commit 6762a41a5de5bba5815912ecea2449a89b1ad0e2 Steve Reed committed Aug 27, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 stats.js
View
@@ -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;

0 comments on commit 6762a41

Please sign in to comment.