Skip to content

Commit

Permalink
Merge branch 'p/debugupdates' into m/testmerge
Browse files Browse the repository at this point in the history
Conflicts:
	stats.js
  • Loading branch information
david raistrick committed Jan 17, 2013
2 parents c090c98 + 82bf445 commit 4137147
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
StatsD [![Build Status](https://secure.travis-ci.org/etsy/statsd.png)](http://travis-ci.org/etsy/statsd)
StatsD [![Build Status](https://travis-ci.org/etsy/statsd.png?branch=backends-as-packages)](https://travis-ci.org/etsy/statsd)
======

A network daemon that runs on the [Node.js][node] platform and
Expand Down
15 changes: 9 additions & 6 deletions backends/graphite.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
*/

var net = require('net'),
util = require('util');
logger = require('../lib/logger');

// this will be instantiated to the logger
var l;

var debug;
var flushInterval;
Expand Down Expand Up @@ -52,7 +55,7 @@ var post_stats = function graphite_post_stats(statString) {
var graphite = net.createConnection(graphitePort, graphiteHost);
graphite.addListener('error', function(connectionException){
if (debug) {
util.log(connectionException);
l.log(connectionException);
}
});
graphite.on('connect', function() {
Expand All @@ -66,7 +69,7 @@ var post_stats = function graphite_post_stats(statString) {
});
} catch(e){
if (debug) {
util.log(e);
l.log(e);
}
graphiteStats.last_exception = Math.round(new Date().getTime() / 1000);
}
Expand Down Expand Up @@ -160,19 +163,19 @@ var flush_stats = function graphite_flush(ts, metrics) {
}
}
post_stats(statString);
// lets debug log a few of our metrics
if (debug) {
util.log("DEBUG: numStats: " + numStats);
l.log("numStats: " + numStats);
}
};

var backend_status = function graphite_status(writeCb) {
for (stat in graphiteStats) {
for (var stat in graphiteStats) {
writeCb(null, 'graphite', stat, graphiteStats[stat]);
}
};

exports.init = function graphite_init(startup_time, config, events) {
l = new logger.Logger(config.log || {});
debug = config.debug;
graphiteHost = config.graphiteHost;
graphitePort = config.graphitePort;
Expand Down
2 changes: 1 addition & 1 deletion exampleConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Optional Variables:
e.g. [ { host: '10.10.10.10', port: 8125 },
{ host: 'observer', port: 88125 } ]
repeaterProtocol: whether to use udp4 or udp4 for repeaters.
repeaterProtocol: whether to use udp4 or udp6 for repeaters.
["udp4" or "udp6", default: "udp4"]
*/
{
Expand Down
48 changes: 21 additions & 27 deletions stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function loadBackend(config, name) {
var backendmod = require(name);

if (config.debug) {
l.log("Loading backend: " + name, 'debug');
l.log("Loading backend: " + name, 'DEBUG');
}

var ret = backendmod.init(startup_time, config, backendEvents);
Expand Down Expand Up @@ -69,6 +69,7 @@ function flushMetrics() {

// Clear the counters
conf.deleteCounters = conf.deleteCounters || false;
<<<<<<< HEAD

// handle the case where these vars are not setup - for this patch to work w/o requiring
// the statsPrefix patch
Expand All @@ -80,24 +81,8 @@ function flushMetrics() {
packets_received = prefixStats + ".packets_received";

for (key in metrics.counters) {
if (conf.deleteCounters) {
if (key == packets_received || key == bad_lines_seen) {
// if (conf.debug) {
// l.log("resetting stats key: " + key);
// }
metrics.counters[key] = 0;
} else {
//if (conf.debug) {
// l.log("deleting key: " + key);
//}
delete(metrics.counters[key]);
}
} else {
metrics.counters[key] = 0;
}
}

// Clear the timers
=======
for (var key in metrics.counters) {
conf.deleteTimers = conf.deleteTimers || false;
for (key in metrics.timers) {
if (conf.deleteTimers) {
Expand All @@ -123,6 +108,15 @@ function flushMetrics() {
for (key in metrics.gauges) {
delete(metrics.gauges[key]);
}
=======
for (var key in metrics.timers) {
metrics.timers[key] = [];
}

// Clear the sets
for (var key in metrics.sets) {
metrics.sets[key] = new set.Set();
>>>>>>> p/debugupdates
}
});

Expand Down Expand Up @@ -159,7 +153,7 @@ config.configFile(process.argv[2], function (config, oldConfig) {
l.log("\nCounters:\n" + util.inspect(counters) +
"\nTimers:\n" + util.inspect(timers) +
"\nSets:\n" + util.inspect(sets) +
"\nGauges:\n" + util.inspect(gauges), 'debug');
"\nGauges:\n" + util.inspect(gauges), 'DEBUG');
}, config.debugInterval || 10000);
}

Expand All @@ -184,7 +178,7 @@ config.configFile(process.argv[2], function (config, oldConfig) {
counters[packets_received]++;
var metrics = msg.toString().split("\n");

for (midx in metrics) {
for (var midx in metrics) {
if (config.dumpMessages) {
l.log(metrics[midx].toString());
}
Expand Down Expand Up @@ -284,8 +278,8 @@ config.configFile(process.argv[2], function (config, oldConfig) {
};

// Loop through the base stats
for (group in stats) {
for (metric in stats[group]) {
for (var group in stats) {
for (var metric in stats[group]) {
stat_writer(group, metric, stats[group][metric]);
}
}
Expand Down Expand Up @@ -322,23 +316,23 @@ config.configFile(process.argv[2], function (config, oldConfig) {
break;

case "delcounters":
for (index in cmdline) {
for (var index in cmdline) {
delete counters[cmdline[index]];
stream.write("deleted: " + cmdline[index] + "\n");
}
stream.write("END\n\n");
break;

case "deltimers":
for (index in cmdline) {
for (var index in cmdline) {
delete timers[cmdline[index]];
stream.write("deleted: " + cmdline[index] + "\n");
}
stream.write("END\n\n");
break;

case "delgauges":
for (index in cmdline) {
for (var index in cmdline) {
delete gauges[cmdline[index]];
stream.write("deleted: " + cmdline[index] + "\n");
}
Expand Down Expand Up @@ -390,7 +384,7 @@ config.configFile(process.argv[2], function (config, oldConfig) {
var key;
var sortedKeys = [];

for (key in keyCounter) {
for (var key in keyCounter) {
sortedKeys.push([key, keyCounter[key]]);
}

Expand Down

0 comments on commit 4137147

Please sign in to comment.