Skip to content

Commit

Permalink
Merge pull request #5 from intellifylearning/optimize
Browse files Browse the repository at this point in the history
support blacklisting
  • Loading branch information
Prashant Nayak authored Sep 17, 2016
2 parents 0613935 + c6e74fa commit 5354f30
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/aws-cloudwatch-statsd-backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ CloudwatchBackend.prototype.processKey = function(key) {
};
};

CloudwatchBackend.prototype.isBlacklisted = function(key) {

if (this.config.blacklist && this.config.blacklist.length > 0 && this.config.blacklist.indexOf(key) !== -1) {
// console.log("Key (counter) " + key + " is blacklisted");
return true;
}

return false;
};

CloudwatchBackend.prototype.chunk = function(arr, chunkSize) {

var groups = [],
Expand Down Expand Up @@ -103,6 +113,10 @@ CloudwatchBackend.prototype.flush = function(timestamp, metrics) {
continue;
}

if (this.isBlacklisted(key)) {
continue;
}

var names = this.config.processKeyForNamespace ? this.processKey(key) : {};
namespace = this.config.namespace || names.namespace || "AwsCloudWatchStatsdBackend";
var metricName = this.config.metricName || names.metricName || key;
Expand All @@ -127,6 +141,10 @@ CloudwatchBackend.prototype.flush = function(timestamp, metrics) {
continue;
}

if (this.isBlacklisted(key)) {
continue;
}

var values = timers[key].sort(function(a, b) {
return a - b;
});
Expand Down Expand Up @@ -179,6 +197,10 @@ CloudwatchBackend.prototype.flush = function(timestamp, metrics) {
continue;
}

if (this.isBlacklisted(key)) {
continue;
}

var names = this.config.processKeyForNamespace ? this.processKey(key) : {};
namespace = this.config.namespace || names.namespace || "AwsCloudWatchStatsdBackend";
var metricName = this.config.metricName || names.metricName || key;
Expand All @@ -202,6 +224,10 @@ CloudwatchBackend.prototype.flush = function(timestamp, metrics) {
continue;
}

if (this.isBlacklisted(key)) {
continue;
}

var names = this.config.processKeyForNamespace ? this.processKey(key) : {};
namespace = this.config.namespace || names.namespace || "AwsCloudWatchStatsdBackend";
var metricName = this.config.metricName || names.metricName || key;
Expand Down

0 comments on commit 5354f30

Please sign in to comment.