Skip to content

Commit

Permalink
whitelist takes precedence over blacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
Prashant Nayak committed Sep 18, 2016
1 parent 29ef047 commit 2ce479d
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions lib/aws-cloudwatch-statsd-backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ CloudwatchBackend.prototype.processKey = function(key) {
CloudwatchBackend.prototype.isBlacklisted = function(key) {

var blacklisted = false;

// First check if key is whitelisted
if (this.config.whitelist && this.config.whitelist.length > 0 && this.config.whitelist.indexOf(key) >= 0) {
// console.log("Key (counter) " + key + " is whitelisted");
return false;
}

if (this.config.blacklist && this.config.blacklist.length > 0) {
for (var i = 0; i < this.config.blacklist.length; i++) {
if (key.indexOf(this.config.blacklist[i]) >= 0) {
Expand Down Expand Up @@ -112,11 +119,6 @@ CloudwatchBackend.prototype.flush = function(timestamp, metrics) {
if (key.indexOf('statsd.') == 0)
continue;

if (this.config.whitelist && this.config.whitelist.length > 0 && this.config.whitelist.indexOf(key) == -1) {
// console.log("Key (counter) " + key + " not in whitelist");
continue;
}

if (this.isBlacklisted(key)) {
continue;
}
Expand All @@ -140,11 +142,6 @@ CloudwatchBackend.prototype.flush = function(timestamp, metrics) {
for (key in timers) {
if (timers[key].length > 0) {

if (this.config.whitelist && this.config.whitelist.length > 0 && this.config.whitelist.indexOf(key) == -1) {
// console.log("Key (counter) " + key + " not in whitelist");
continue;
}

if (this.isBlacklisted(key)) {
continue;
}
Expand Down Expand Up @@ -196,11 +193,6 @@ CloudwatchBackend.prototype.flush = function(timestamp, metrics) {
var currentGaugeMetrics = [];
for (key in gauges) {

if (this.config.whitelist && this.config.whitelist.length > 0 && this.config.whitelist.indexOf(key) == -1) {
// console.log("Key (counter) " + key + " not in whitelist");
continue;
}

if (this.isBlacklisted(key)) {
continue;
}
Expand All @@ -223,11 +215,6 @@ CloudwatchBackend.prototype.flush = function(timestamp, metrics) {
var currentSetMetrics = [];
for (key in sets) {

if (this.config.whitelist && this.config.whitelist.length > 0 && this.config.whitelist.indexOf(key) == -1) {
// console.log("Key (counter) " + key + " not in whitelist");
continue;
}

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

0 comments on commit 2ce479d

Please sign in to comment.