From c7fd21ae5247672d8f1867b449b3b8e3fe080a93 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Fri, 29 Jan 2016 13:59:37 -0500 Subject: [PATCH] Fix up flake8 and unit test failures * Make sure we default to localhost to not fail at the GAI check * Cleanup some flake8 issues in the metrics module --- awx/lib/metrics.py | 19 ++++++++----------- awx/settings/defaults.py | 3 +++ awx/settings/development_quiet.py | 3 +++ 3 files changed, 14 insertions(+), 11 deletions(-) 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'