Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #55 from bmarini/global-prefix-first
Browse files Browse the repository at this point in the history
Add globalPrefix before performing sourceRegex match
  • Loading branch information
mheffner committed Sep 10, 2015
2 parents 42ce5a1 + 96918a4 commit 41c358b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/librato.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,15 @@ var flush_stats = function librato_flush(ts, metrics)
countStat = typeof countStat !== 'undefined' ? countStat : true;

var match;
if (sourceRegex && (match = measure.name.match(sourceRegex)) && match[1]) {
// Use first capturing group as source name
var measureName = globalPrefix + measure.name;

// Use first capturing group as source name
if (sourceRegex && (match = measureName.match(sourceRegex)) && match[1]) {
measure.source = sanitize_name(match[1]);
// Remove entire matching string from the measure name & add global prefix.
measure.name = globalPrefix + sanitize_name(measure.name.slice(0, match.index) + measure.name.slice(match.index + match[0].length));
measure.name = sanitize_name(measureName.slice(0, match.index) + measureName.slice(match.index + match[0].length));
} else {
measure.name = globalPrefix + sanitize_name(measure.name);
measure.name = sanitize_name(measureName);
}

if (brokenMetrics[measure.name]) {
Expand Down

0 comments on commit 41c358b

Please sign in to comment.