diff --git a/lib/librato.js b/lib/librato.js
index <HASH>..<HASH> 100644
--- a/lib/librato.js
+++ b/lib/librato.js
@@ -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]) {
Add globalPrefix before performing sourceRegex match