diff --git a/middleware/statsd/statsd_middleware.py b/middleware/statsd/statsd_middleware.py index 901696b99a..ce36efcb66 100644 --- a/middleware/statsd/statsd_middleware.py +++ b/middleware/statsd/statsd_middleware.py @@ -1,7 +1,7 @@ import time from django.utils.deprecation import MiddlewareMixin -# from monitoring.statsd.metrics import statsd, REQUEST_COUNT_METRIC_NAME, REQUEST_LATENCY_METRIC_NAME +from monitoring.statsd.metrics import statsd, REQUEST_COUNT_METRIC_NAME, REQUEST_LATENCY_METRIC_NAME class StatsdMetricsMiddleware(MiddlewareMixin): @@ -17,26 +17,24 @@ def get_view_name(self, request): return view_name def process_response(self, request, response): - # TODO: Enable statsd metric push once production docker setup is ready - # statsd.increment( - # REQUEST_COUNT_METRIC_NAME, - # tags=[ - # "service:django_worker", - # "method:%s" % request.method, - # "view:%s" % self.get_view_name(request), - # "status:%s" % str(response.status_code), - # ], - # ) - - # resp_time = (time.time() - request.start_time) * 1000 - - # statsd.histogram( - # REQUEST_LATENCY_METRIC_NAME, - # resp_time, - # tags=[ - # "service:django_worker", - # "view:%s" % self.get_view_name(request), - # ], - # ) - + statsd.increment( + REQUEST_COUNT_METRIC_NAME, + tags=[ + "service:django_worker", + "method:%s" % request.method, + "view:%s" % self.get_view_name(request), + "status:%s" % str(response.status_code), + ], + ) + + resp_time = (time.time() - request.start_time) * 1000 + + statsd.histogram( + REQUEST_LATENCY_METRIC_NAME, + resp_time, + tags=[ + "service:django_worker", + "view:%s" % self.get_view_name(request), + ], + ) return response diff --git a/monitoring/statsd/metrics.py b/monitoring/statsd/metrics.py index f46c5b9dd1..be7d14f9b6 100644 --- a/monitoring/statsd/metrics.py +++ b/monitoring/statsd/metrics.py @@ -14,6 +14,5 @@ def increment_statsd_counter(metric_name, tags, inc_value): - # TODO: Enable statsd metric increment once production docker setup is ready - # statsd.increment(metric_name, inc_value, tags=tags) + statsd.increment(metric_name, inc_value, tags=tags) return