track response codes with statsd
This commit is contained in:
Родитель
d80aaa81db
Коммит
30f70b6e38
|
@ -18,6 +18,7 @@ import commonware.log
|
|||
import MySQLdb as mysql
|
||||
import tower
|
||||
import jingo
|
||||
from statsd import statsd
|
||||
|
||||
import amo
|
||||
from . import urlresolvers
|
||||
|
@ -174,3 +175,13 @@ class TimingMiddleware(object):
|
|||
msg = '{method} "{url}" ({code}) {time:.2f} [{auth}]'.format(**d)
|
||||
timing_log.info(msg)
|
||||
return response
|
||||
|
||||
|
||||
class GraphiteMiddleware(object):
|
||||
|
||||
def process_response(self, request, response):
|
||||
statsd.incr('response.%s' % response.status_code)
|
||||
return response
|
||||
|
||||
def process_exception(self, request, exception):
|
||||
statsd.incr('response.500')
|
||||
|
|
|
@ -243,6 +243,7 @@ def JINJA_CONFIG():
|
|||
MIDDLEWARE_CLASSES = (
|
||||
# AMO URL middleware comes first so everyone else sees nice URLs.
|
||||
'amo.middleware.TimingMiddleware',
|
||||
'amo.middleware.GraphiteMiddleware',
|
||||
'amo.middleware.LocaleAndAppURLMiddleware',
|
||||
# Mobile detection should happen in Zeus.
|
||||
'mobility.middleware.DetectMobileMiddleware',
|
||||
|
@ -986,3 +987,7 @@ TASK_USER_ID = 4757633
|
|||
# If this is False, tasks and other jobs that send non-critical emails should
|
||||
# use a fake email backend.
|
||||
SEND_REAL_EMAIL = False
|
||||
|
||||
STATSD_HOST = 'localhost'
|
||||
STATSD_PORT = 8125
|
||||
STATSD_PREFIX = 'amo'
|
||||
|
|
Загрузка…
Ссылка в новой задаче