Skip to content

Commit

Permalink
Merge pull request #76 from rodcloutier/Fixed_report_time_missing_in_…
Browse files Browse the repository at this point in the history
…meta_timing

Fixed report handling timing not included in meta-timing
  • Loading branch information
mtford90 committed Sep 6, 2015
2 parents 14a7983 + e14d9e9 commit 35123d9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion silk/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def _apply_dynamic_mappings(self):
def process_request(self, request):
request_model = None
if _should_intercept(request):
Logger.debug('process_request')
request.silk_is_intercepted = True
self._apply_dynamic_mappings()
if not hasattr(SQLCompiler, '_execute_sql'):
Expand All @@ -96,6 +97,7 @@ def process_request(self, request):


def _process_response(self, response):
Logger.debug('Process response')
with silk_meta_profiler():
collector = DataCollector()
collector.stop_python_profiler()
Expand All @@ -105,10 +107,15 @@ def _process_response(self, response):
silk_response.save()
silk_request.end_time = timezone.now()
collector.finalise()
silk_request.save()
else:
Logger.error(
'No request model was available when processing response. Did something go wrong in process_request/process_view?')
# Need to save the data outside the silk_meta_profiler
# Otherwise the meta time collected in the context manager
# is not taken in account
if silk_request:
silk_request.save()
Logger.debug('Process response done.')


def process_response(self, request, response):
Expand Down

0 comments on commit 35123d9

Please sign in to comment.