From 0a1a63c87f46e112bdfc8ddb84ead8e522b3a555 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Wed, 18 Sep 2013 10:59:02 -0400 Subject: [PATCH] Blacklist some webreq urls that we don't want to store for metrics (imported from commit 60def99010e5c55e77acc65aa516459c6e4ffaae) --- zerver/middleware.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/zerver/middleware.py b/zerver/middleware.py index 266d6af4c6..3c86f73d9f 100644 --- a/zerver/middleware.py +++ b/zerver/middleware.py @@ -56,7 +56,9 @@ class LogRequests(object): statsd_path = 'webreq' else: statsd_path = "webreq.%s" % (request.path[1:].replace('/', '.'),) - + blacklisted_requests = ['do_confirm', 'accounts.login.openid', 'send_confirm', + 'eventslast_event_id', 'webreq.content'] + suppress_statsd = any((blacklisted in statsd_path for blacklisted in blacklisted_requests)) # The reverse proxy might have sent us the real external IP remote_ip = request.META.get('HTTP_X_REAL_IP') @@ -89,8 +91,9 @@ class LogRequests(object): memcached_output = " (mem: %s/%s)" % (format_timedelta(memcached_time_delta), memcached_count_delta) - statsd.timing("%s.memcached.time" % (statsd_path,), timedelta_ms(memcached_time_delta)) - statsd.incr("%s.memcached.querycount" % (statsd_path,), memcached_count_delta) + if not suppress_statsd: + statsd.timing("%s.memcached.time" % (statsd_path,), timedelta_ms(memcached_time_delta)) + statsd.incr("%s.memcached.querycount" % (statsd_path,), memcached_count_delta) bugdown_output = "" if hasattr(request, '_bugdown_time_start'): @@ -107,8 +110,9 @@ class LogRequests(object): bugdown_output = " (md: %s/%s)" % (format_timedelta(bugdown_time_delta), bugdown_count_delta) - statsd.timing("%s.markdown.time" % (statsd_path,), timedelta_ms(bugdown_time_delta)) - statsd.incr("%s.markdown.count" % (statsd_path,), bugdown_count_delta) + if not suppress_statsd: + statsd.timing("%s.markdown.time" % (statsd_path,), timedelta_ms(bugdown_time_delta)) + statsd.incr("%s.markdown.count" % (statsd_path,), bugdown_count_delta) # Get the amount of time spent doing database queries db_time_output = "" @@ -117,10 +121,11 @@ class LogRequests(object): db_time_output = " (db: %s/%sq)" % (format_timedelta(query_time), len(connection.queries)) - # Log ms, db ms, and num queries to statsd - statsd.timing("%s.dbtime" % (statsd_path,), timedelta_ms(query_time)) - statsd.incr("%s.dbq" % (statsd_path, ), len(connection.queries)) - statsd.timing("%s.total" % (statsd_path,), timedelta_ms(time_delta)) + if not suppress_statsd: + # Log ms, db ms, and num queries to statsd + statsd.timing("%s.dbtime" % (statsd_path,), timedelta_ms(query_time)) + statsd.incr("%s.dbq" % (statsd_path, ), len(connection.queries)) + statsd.timing("%s.total" % (statsd_path,), timedelta_ms(time_delta)) # Get the requestor's email address and client, if available. try: