Skip to content

Commit

Permalink
calculate duration from response_start_time attribute if found
Browse files Browse the repository at this point in the history
  • Loading branch information
ehabel-kady committed Mar 14, 2024
1 parent 2bb4200 commit adb3037
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion django_datadog_logger/middleware/request_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def log_response(self, request, response):
log_entry_dict = {"http.status_code": response.status_code}

if hasattr(request, "request_start_time"):
duration_seconds = time.time() - request.request_start_time
duration_seconds = getattr(response, "response_start_time", time.time()) - request.request_start_time
log_entry_dict["duration"] = duration_seconds * 1000000000.0

if 400 <= response.status_code < 500:
Expand Down

0 comments on commit adb3037

Please sign in to comment.