Changes between Version 1 and Version 2 of Ticket #25704


Ignore:
Timestamp:
11/07/2015 01:35:25 PM (6 years ago)
Author:
Andrei Fokau
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #25704

    • Property Triage Stage changed from Accepted to Unreviewed
  • Ticket #25704 – Description

    v1 v2  
    1919}}}
    2020
     21or via middleware
     22
     23{{{
     24#!python
     25class ResponseTimeMiddleware(object):
     26    def process_view(self, request, view_func, view_args, view_kwargs):
     27        start = time.time()
     28        response = view_func(request, *view_args, **view_kwargs)
     29
     30        if response and getattr(response, 'is_rendered', True) is False:
     31            response.rendered_content
     32
     33        logging.getLogger('response_time').debug(
     34            'Response time %dms', (time.time() - start) * 1000)
     35        return response
     36}}}
     37
     38
    2139It seems easy to add it in the WSGIRequestHandler e.g. https://github.com/django/django/pull/5606. The response time is slightly longer than actual response time due to late measuring but think an easy implementation is better than the exact duration.
    2240
Back to Top