Skip to content
Browse files

initial commit

  • Loading branch information...
0 parents commit 31e3fdbdcbad7a0f070a84a3c8dd04cbf53cb55a @dbhowell dbhowell committed
Showing with 72 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +52 −0 lib/index.js
  3. +19 −0 package.json
1 .gitignore
@@ -0,0 +1 @@
+node_modules
52 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 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.
Something went wrong with that request. Please try again.