From b54ae961d020d34f3e87f82a72d39b23fff6e9f4 Mon Sep 17 00:00:00 2001
From: Andy Trevorah <andy@troupe.co>
Date: Thu, 24 Jul 2014 17:10:54 +0100
Subject: [PATCH] added staging tags via vanilla node-statsd

---
 lib/stats.js | 9 +++++----
 package.json | 2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/stats.js b/lib/stats.js
index 8303689..eb8a47e 100644
--- a/lib/stats.js
+++ b/lib/stats.js
@@ -98,13 +98,14 @@ exports.create = function(options) {
   if (statsdEnabled) {
     var StatsD = require('node-statsd').StatsD;
     var statsdClient = new StatsD({ prefix: config.get('stats:statsd:prefix'), host: '127.0.0.1' });
+    var tags = config.get('STAGING') ? ['staging'] : [];
 
     statsdClient.socket.on('error', function(error) {
       return emergencyLog("Error in statsd socket: " + error, { exception: error });
     });
 
     statsHandlers.event.push(function(eventName) {
-      statsdClient.increment(eventName);
+      statsdClient.increment(eventName, null, null, tags);
     });
 
     statsHandlers.eventHF.push(function(eventName, count, frequency) {
@@ -112,18 +113,18 @@ exports.create = function(options) {
       if(!frequency) frequency = 0.1;
 
       /* Only send to the server one tenth of the time */
-      statsdClient.increment(eventName, count, frequency);
+      statsdClient.increment(eventName, count, frequency, tags);
     });
 
     statsHandlers.gaugeHF.push(function(gaugeName, value, frequency) {
       if(!frequency) frequency = 0.1;
 
       /* Only send to the server one tenth of the time */
-      statsdClient.gauge(gaugeName, value, frequency);
+      statsdClient.gauge(gaugeName, value, frequency, tags);
     });
 
     statsHandlers.responseTime.push(function(timerName, duration) {
-      statsdClient.timing(timerName, duration);
+      statsdClient.timing(timerName, duration, null, tags);
     });
   }
 
diff --git a/package.json b/package.json
index 295faf4..f73aa7d 100644
--- a/package.json
+++ b/package.json
@@ -32,7 +32,7 @@
     "redis-sentinel-client": "^0.1.5",
     "raven": "^0.6.3",
     "cube": "^0.2.12",
-    "node-statsd": "0.0.7",
+    "node-statsd": "sivy/node-statsd",
     "mixpanel": "0.0.20",
     "underscore": "^1.6.0",
     "clockout": "0.0.1",
-- 
GitLab