Permalink
Browse files

Use different module to transmit to statsD

  • Loading branch information...
1 parent 194df91 commit 57b82e5252efa11ca1de5b9fdd4f278086dbfb6e @TheDeveloper committed Mar 8, 2013
Showing with 5 additions and 24 deletions.
  1. +3 −6 lib/abacus.js
  2. +2 −2 package.json
  3. +0 −16 test/suite.js
View
@@ -1,5 +1,5 @@
var util = require('util');
-var statsD = require('node-statsd').StatsD;
+var statsD = require('statsd-client');
var counters = function(opts){
var self = this;
@@ -11,10 +11,7 @@ var counters = function(opts){
// Start a statsD connection if configured
if(self.opts.statsD){
var statsDConfig = self.opts.statsD;
- self.statsD = new statsD(statsDConfig.connection.host, statsDConfig.connection.port);
- self.statsD.socket.on('error', function(e){
- return self.debug('Error on statsD socket: %s', e);
- });
+ self.statsD = new statsD(statsDConfig.connection);
}
if(self.opts.flushFrequency){
@@ -53,7 +50,7 @@ counters.prototype.flush = function(){
var q = [];
for(var counter in this.counters){
var value = this.counters[counter];
- q.push(this.statsD.update_stats.bind(this.statsD, this.opts.statsD.metricPrefix+counter, value));
+ q.push(this.statsD.counter.bind(this.statsD, this.opts.statsD.metricPrefix+counter, value));
if(this.opts.resetOnFlush)
this.counters[counter] = 0;
}
View
@@ -21,8 +21,8 @@
"author": "Geoff Wagstaff",
"license": "MIT",
"dependencies": {
- "node-statsd": "0.0.3",
- "should": "~1.2.0"
+ "should": "~1.2.0",
+ "statsd-client": "0.0.12"
},
"devDependencies": {
"mocha": "~1.6.0"
View
@@ -46,22 +46,6 @@ describe('When persisting to statsD', function(){
});
});
- it('Invokes debug handler if there was an error with statsD', function(done){
- var statsDConfig = {
- connection: {
- host: 'badhost',
- port: 9853
- }
- };
- var metrics = new abacus({statsD: statsDConfig, debug: true});
- metrics.increment('dontCrash');
-
- metrics = new abacus({statsD: statsDConfig, debug: function(){
- done();
- }});
- metrics.increment('dontCrash');
- });
-
it('Flushes counters to statsD periodically', function(done){
var metrics = new abacus({statsD: statsDConfig, resetOnFlush: true, flushFrequency: 1});
metrics.increment('flushyFlush');

0 comments on commit 57b82e5

Please sign in to comment.