diff --git a/awx/lib/metrics.py b/awx/lib/metrics.py index 1795e28dd3..be4bd8dedf 100644 --- a/awx/lib/metrics.py +++ b/awx/lib/metrics.py @@ -2,28 +2,25 @@ from __future__ import absolute_import import logging +from functools import wraps +from django_statsd.clients import statsd logger = logging.getLogger(__name__) -from functools import wraps - -from django_statsd.clients import statsd - def task_timer(fn): @wraps(fn) def __wrapped__(self, *args, **kwargs): statsd.incr('tasks.{}.{}.count'.format( - self.name.rsplit('.', 1)[-1], - fn.__name__ - )) + self.name.rsplit('.', 1)[-1], + fn.__name__)) with statsd.timer('tasks.{}.{}.timer'.format( self.name.rsplit('.', 1)[-1], - fn.__name__ - )): + fn.__name__)): return fn(self, *args, **kwargs) return __wrapped__ + class BaseTimer(object): def __init__(self, name, prefix=None): self.name = name.rsplit('.', 1)[-1] @@ -34,8 +31,8 @@ class BaseTimer(object): @wraps(fn) def __wrapped__(obj, *args, **kwargs): statsd.incr('{}.{}.count'.format( - self.name, - fn.__name__ + self.name, + fn.__name__ )) with statsd.timer('{}.{}.timer'.format( self.name, diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index de05ef930f..e338ef14b6 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -973,3 +973,6 @@ LOGGING = { }, } } + +STATSD_CLIENT = 'django_statsd.clients.null' +STATSD_HOST = 'localhost' diff --git a/awx/settings/development_quiet.py b/awx/settings/development_quiet.py index 63e5099691..a3461aed7b 100644 --- a/awx/settings/development_quiet.py +++ b/awx/settings/development_quiet.py @@ -13,4 +13,7 @@ from development import * # NOQA DEBUG = False TEMPLATE_DEBUG = DEBUG SQL_DEBUG = DEBUG + +# Statistics Gathering STATSD_CLIENT = 'django_statsd.clients.null' +STATSD_HOST = 'localhost'