Only init the statsd client if enabled - allows us to switch it off if not internet access

This commit is contained in:
Martyn Inglis
2016-08-30 10:37:06 +01:00
parent 1834522824
commit 58a89a3a80

View File

@@ -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