Skip to content

Commit

Permalink
Merge pull request #258 from etsy/optimizations
Browse files Browse the repository at this point in the history
More graphite backend Optimizations
  • Loading branch information
draco2003 committed Mar 2, 2013
2 parents 644ec36 + 54ab8a5 commit 7d1ce9d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions backends/graphite.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ var prefixGauge;
var prefixSet;

// set up namespaces
var legacyNamespace = true;
var legacyNamespace = true;
var globalNamespace = [];
var counterNamespace = [];
var timerNamespace = [];
var gaugesNamespace = [];
var setsNamespace = [];
var setsNamespace = [];

var graphiteStats = {};

Expand All @@ -57,11 +57,11 @@ var post_stats = function graphite_post_stats(statString) {
graphite.on('connect', function() {
var ts = Math.round(new Date().getTime() / 1000);
var ts_suffix = ' ' + ts + "\n";
var namespace = globalNamespace.concat(prefixStats);
statString += namespace.join(".") + '.graphiteStats.last_exception ' + last_exception + ts_suffix;
statString += namespace.join(".") + '.graphiteStats.last_flush ' + last_flush + ts_suffix;
statString += namespace.join(".") + '.graphiteStats.flush_time ' + flush_time + ts_suffix;
statString += namespace.join(".") + '.graphiteStats.flush_length ' + flush_length + ts_suffix;
var namespace = globalNamespace.concat(prefixStats).join(".");
statString += namespace + '.graphiteStats.last_exception ' + last_exception + ts_suffix;
statString += namespace + '.graphiteStats.last_flush ' + last_flush + ts_suffix;
statString += namespace + '.graphiteStats.flush_time ' + flush_time + ts_suffix;
statString += namespace + '.graphiteStats.flush_length ' + flush_length + ts_suffix;
var starttime = Date.now();
this.write(statString);
this.end();
Expand Down Expand Up @@ -117,7 +117,9 @@ var flush_stats = function graphite_flush(ts, metrics) {
statString += the_key + '.' + timer_data_key + ' ' + timer_data[key][timer_data_key] + ts_suffix;
} else {
for (var timer_data_sub_key in timer_data[key][timer_data_key]) {
l.log(timer_data[key][timer_data_key][timer_data_sub_key].toString());
if (debug) {
l.log(timer_data[key][timer_data_key][timer_data_sub_key].toString());
}
statString += the_key + '.' + timer_data_key + '.' + timer_data_sub_key + ' ' +
timer_data[key][timer_data_key][timer_data_sub_key] + ts_suffix;
}
Expand Down

0 comments on commit 7d1ce9d

Please sign in to comment.