From 58a89a3a802d5dedc897d9b4b3ff62b9d8893bed Mon Sep 17 00:00:00 2001 From: Martyn Inglis Date: Tue, 30 Aug 2016 10:37:06 +0100 Subject: [PATCH] Only init the statsd client if enabled - allows us to switch it off if not internet access --- app/clients/statsd/statsd_client.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/clients/statsd/statsd_client.py b/app/clients/statsd/statsd_client.py index 6b127da93..19e89557e 100644 --- a/app/clients/statsd/statsd_client.py +++ b/app/clients/statsd/statsd_client.py @@ -3,15 +3,17 @@ from statsd import StatsClient class StatsdClient(StatsClient): def init_app(self, app, *args, **kwargs): - StatsClient.__init__( - self, - app.config.get('STATSD_HOST'), - app.config.get('STATSD_PORT'), - prefix=app.config.get('STATSD_PREFIX') - ) self.active = app.config.get('STATSD_ENABLED') self.namespace = app.config.get('NOTIFY_ENVIRONMENT') + ".notifications.api." + if self.active: + StatsClient.__init__( + self, + app.config.get('STATSD_HOST'), + app.config.get('STATSD_PORT'), + prefix=app.config.get('STATSD_PREFIX') + ) + def format_stat_name(self, stat): return self.namespace + stat