Skip to content
This repository has been archived by the owner on Feb 1, 2018. It is now read-only.

Commit

Permalink
Add the ability to send configured percentile values using the standa…
Browse files Browse the repository at this point in the history
…rd statsd config.percentThreshold. Default to false since it wasn't in previous versions and we want to keep back compat.
  • Loading branch information
ekilby committed Apr 17, 2014
1 parent d02e2a6 commit 1b0de36
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/stackdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ function StackdriverBackend(startupTime, config, emitter) {
this.sendTimerMaxes = ('sendTimerMaxes' in config.stackdriver) ? config.stackdriver.sendTimerMaxes : true;
this.sendTimerSums = ('sendTimerSums' in config.stackdriver) ? config.stackdriver.sendTimerSums : true;
this.sendTimerAvgs = ('sendTimerAvgs' in config.stackdriver) ? config.stackdriver.sendTimerAvgs : true;

// Timer percentiles are set to false by default since we didn't have those in earlier revs
this.sendTimerPercentiles = ('sendTimerPercentiles' in config.stackdriver) ? config.stackdriver.sendTimerPercentiles : false;

// Use the default 90th percentile as supplied in statsd if none are configured
this.percentileValues = ('percentThreshold' in config) ? config.percentThreshold : ['90'];

if (this.debug) {
util.log('Stackdriver Backend set to report timer percentiles ' + this.percentileValues);
}

this.sendSets = ('sendSets' in config.stackdriver) ? config.stackdriver.sendSets : true;

this.stackdriverHost = 'custom-gateway.stackdriver.com';
Expand Down Expand Up @@ -304,6 +315,16 @@ StackdriverBackend.prototype.flush = function(timestamp, metrics) {
collected_at: timestamp
});
}
if (this.sendTimerPercentiles) {
// send a point for each configured percentile, defaults to just 90th per statsd default
for (var i=0; i < this.percentileValues.length; i++) {
this.add_point_to_message(stackdriverMessage, {
name : timer_key + "." + this.percentileValues[i] + "_pct",
value : metrics.timer_data[timer_key]["upper_" + this.percentileValues[i]],
collected_at: timestamp
});
}
}
}
}

Expand Down

0 comments on commit 1b0de36

Please sign in to comment.