mirror of
https://github.com/ansible/awx.git
synced 2026-05-06 08:57:35 -02:30
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
This commit is contained in:
@@ -2,28 +2,25 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from functools import wraps
|
||||||
|
from django_statsd.clients import statsd
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
from functools import wraps
|
|
||||||
|
|
||||||
from django_statsd.clients import statsd
|
|
||||||
|
|
||||||
|
|
||||||
def task_timer(fn):
|
def task_timer(fn):
|
||||||
@wraps(fn)
|
@wraps(fn)
|
||||||
def __wrapped__(self, *args, **kwargs):
|
def __wrapped__(self, *args, **kwargs):
|
||||||
statsd.incr('tasks.{}.{}.count'.format(
|
statsd.incr('tasks.{}.{}.count'.format(
|
||||||
self.name.rsplit('.', 1)[-1],
|
self.name.rsplit('.', 1)[-1],
|
||||||
fn.__name__
|
fn.__name__))
|
||||||
))
|
|
||||||
with statsd.timer('tasks.{}.{}.timer'.format(
|
with statsd.timer('tasks.{}.{}.timer'.format(
|
||||||
self.name.rsplit('.', 1)[-1],
|
self.name.rsplit('.', 1)[-1],
|
||||||
fn.__name__
|
fn.__name__)):
|
||||||
)):
|
|
||||||
return fn(self, *args, **kwargs)
|
return fn(self, *args, **kwargs)
|
||||||
return __wrapped__
|
return __wrapped__
|
||||||
|
|
||||||
|
|
||||||
class BaseTimer(object):
|
class BaseTimer(object):
|
||||||
def __init__(self, name, prefix=None):
|
def __init__(self, name, prefix=None):
|
||||||
self.name = name.rsplit('.', 1)[-1]
|
self.name = name.rsplit('.', 1)[-1]
|
||||||
@@ -34,8 +31,8 @@ class BaseTimer(object):
|
|||||||
@wraps(fn)
|
@wraps(fn)
|
||||||
def __wrapped__(obj, *args, **kwargs):
|
def __wrapped__(obj, *args, **kwargs):
|
||||||
statsd.incr('{}.{}.count'.format(
|
statsd.incr('{}.{}.count'.format(
|
||||||
self.name,
|
self.name,
|
||||||
fn.__name__
|
fn.__name__
|
||||||
))
|
))
|
||||||
with statsd.timer('{}.{}.timer'.format(
|
with statsd.timer('{}.{}.timer'.format(
|
||||||
self.name,
|
self.name,
|
||||||
|
|||||||
@@ -973,3 +973,6 @@ LOGGING = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATSD_CLIENT = 'django_statsd.clients.null'
|
||||||
|
STATSD_HOST = 'localhost'
|
||||||
|
|||||||
@@ -13,4 +13,7 @@ from development import * # NOQA
|
|||||||
DEBUG = False
|
DEBUG = False
|
||||||
TEMPLATE_DEBUG = DEBUG
|
TEMPLATE_DEBUG = DEBUG
|
||||||
SQL_DEBUG = DEBUG
|
SQL_DEBUG = DEBUG
|
||||||
|
|
||||||
|
# Statistics Gathering
|
||||||
STATSD_CLIENT = 'django_statsd.clients.null'
|
STATSD_CLIENT = 'django_statsd.clients.null'
|
||||||
|
STATSD_HOST = 'localhost'
|
||||||
|
|||||||
Reference in New Issue
Block a user