From 769aa9c0abc0ca50c841fece6d49281b8a85a027 Mon Sep 17 00:00:00 2001 From: Alex Kaplan Date: Fri, 21 Feb 2014 17:59:36 -0800 Subject: [PATCH] Adding whitelist feature to worker.py and settings.py.example --- src/horizon/worker.py | 13 +++++++++++++ src/settings.py.example | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/src/horizon/worker.py b/src/horizon/worker.py index 705e0acc..8512bd7a 100644 --- a/src/horizon/worker.py +++ b/src/horizon/worker.py @@ -45,6 +45,16 @@ def in_skip_list(self, metric_name): return False + def in_include_list(self, metric_name): + """ + Check if the metric is in INCLUDE_LIST. + """ + for to_include in settings.INCLUDE_LIST: + if to_include in metric_name: + return True + + return False + def send_graphite_metric(self, name, value): if settings.GRAPHITE_HOST != '': sock = socket.socket() @@ -87,6 +97,9 @@ def run(self): for metric in chunk: + if settings.INCLUDE_LIST and not self.in_include_list(metric[0]): + continue + # Check if we should skip it if self.in_skip_list(metric[0]): continue diff --git a/src/settings.py.example b/src/settings.py.example index c128fe88..dc671d91 100644 --- a/src/settings.py.example +++ b/src/settings.py.example @@ -217,6 +217,10 @@ SKIP_LIST = [ #'.count_ps', #'.sum', ] +INCLUDE_LIST = [ + #'some.metric.to.include', + # populate this list to selectively include metrics +] """