From d1c0e071706dde5a8ee9032a2591a521b891e447 Mon Sep 17 00:00:00 2001 From: Felix Sperling Date: Wed, 15 May 2013 12:22:35 +0200 Subject: [PATCH] keys of metrics not coming from inapplicationmonitor are not modified anymore --- stats.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/stats.js b/stats.js index 25ae5813..80535eba 100644 --- a/stats.js +++ b/stats.js @@ -16,7 +16,7 @@ function measureForKey (key, fields){ if (fields[1] === undefined) { sys.log('Bad line: ' + fields); } else { - if (!(fields[3] === undefined)) { + if (isInApplicationMonitorMetric(fields)) { prefix = fields[3].replace(/_[a-zA-Z0-9_]*/g, '') .replace(/devbui([0-9]{2})/g, 'bui') .replace(/dev([0-9]{4})/g, 'localdev') @@ -26,13 +26,21 @@ function measureForKey (key, fields){ .replace(/[0-9]+/g, '')+'.' } if (fields[1].trim() == "ms") { - finalKey = prefix + 'timers.' + key ; + if (isInApplicationMonitorMetric(fields)) { + finalKey = prefix + 'timers.' + key ; + } else { + finalKey = key; + } if (! timers[finalKey]) { timers[finalKey] = []; } timers[finalKey].push(Number(fields[0] || 0)); } else { - finalKey = prefix + 'counters.' + key ; + if (isInApplicationMonitorMetric(fields)) { + finalKey = prefix + 'counters.' + key ; + } else { + finalKey = key; + } if (fields[2] && fields[2].match(/^@([\d\.]+)/)) { sampleRate = Number(fields[2].match(/^@([\d\.]+)/)[1]); } @@ -44,6 +52,10 @@ function measureForKey (key, fields){ } } +function isInApplicationMonitorMetric(fields) { + return !(fields[3] === undefined); +} + config.configFile(process.argv[2], function (config, oldConfig) { if (! config.debug && debugInt) {