Skip to content

Commit

Permalink
Compatibility with the new middleware classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
xordoquy committed May 30, 2017
1 parent 903c76b commit eee527b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions django_statsd/middleware.py
Expand Up @@ -7,7 +7,14 @@
from django_statsd.clients import statsd


class GraphiteMiddleware(object):
try:
from django.utils.deprecation import MiddlewareMixin
except ImportError:
class MiddlewareMixin(object):
pass


class GraphiteMiddleware(MiddlewareMixin):

def process_response(self, request, response):
statsd.incr('response.%s' % response.status_code)
Expand All @@ -22,7 +29,7 @@ def process_exception(self, request, exception):
statsd.incr('response.auth.500')


class GraphiteRequestTimingMiddleware(object):
class GraphiteRequestTimingMiddleware(MiddlewareMixin):
"""statsd's timing data per view."""

def process_view(self, request, view_func, view_args, view_kwargs):
Expand Down

0 comments on commit eee527b

Please sign in to comment.