Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dbhowell committed Jun 10, 2012
0 parents commit 31e3fdb
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
node_modules
52 changes: 52 additions & 0 deletions lib/index.js
@@ -0,0 +1,52 @@
var statsd = require('statsd-client'),
util = require('util'),
options = {},
client;

var onFlush = function(time_stamp, metrics) {
console.log(metrics);

for(var key in metrics.gauges) {
var g = metrics.gauges[key];
client.gauge(key, g);
}

for(var key in metrics.timers) {
var t = metrics.timers[key];
t.forEach(function(v) {
client.timing(key, v);
});
}

for(var key in metrics.counters) {
var c = metrics.counters[key];
client.counter(key, c);
}
};

var onStatus = function(callback) {

};

exports.init = function(startup_time, config, events) {
if(!config.statsdHost) {
util.log('statsd-backend: requires \'statsdHost\' option');
return false;
}

if(!config.statsdPort) {
util.log('statsd-backend: requires \'statsdPort\' option');
return false;
}

options.host = config.statsdHost;
options.port = config.statsdPort;
options.debug = config.stastdDebug || false;

client = new statsd(options.host, {port: options.port, debug: options.debug});

events.on('flush', onFlush);
events.on('status', onStatus);

return true;
};
19 changes: 19 additions & 0 deletions package.json
@@ -0,0 +1,19 @@
{
"author": "David Howell <david@dynamicmethods.com.au>",
"name": "statsd-backend",
"version": "0.0.1",
"main": "./lib/index.js",
"description": "A backend for StatsD to emit stats to another StatsD service",
"dependencies": {
"statsd-client": ">=0.0.2"
},
"devDependencies": {},
"optionalDependencies": {},
"engines": {
"node": ">=0.4"
},
"keywords": [
"statsd"
],
"license": "MIT"
}

0 comments on commit 31e3fdb

Please sign in to comment.