@@ -136,14 +136,14 @@ def call(env)
136136 end
137137
138138 elsif collapse_into_single_event?
139- start = Time . now
140-
139+ request_start = Time . now
141140 status , headers , body = @app . call ( env )
141+ request_end = Time . now
142142
143143 Config . instance . logger . info do
144144 http_context = CurrentContext . fetch ( :http )
145145 content_length = safe_to_i ( headers [ CONTENT_LENGTH_KEY ] )
146- duration_ms = ( Time . now - start ) * 1000.0
146+ duration_ms = ( request_end - request_start ) * 1000.0
147147
148148 http_response = HTTPResponse . new (
149149 content_length : content_length ,
@@ -174,8 +174,6 @@ def call(env)
174174
175175 [ status , headers , body ]
176176 else
177- start = Time . now
178-
179177 Config . instance . logger . info do
180178 event_body = capture_request_body? ? request . body_content : nil
181179 http_request = HTTPRequest . new (
@@ -213,12 +211,14 @@ def call(env)
213211 }
214212 end
215213
214+ request_start = Time . now
216215 status , headers , body = @app . call ( env )
216+ request_end = Time . now
217217
218218 Config . instance . logger . info do
219219 event_body = capture_response_body? ? body : nil
220220 content_length = safe_to_i ( headers [ CONTENT_LENGTH_KEY ] )
221- duration_ms = ( Time . now - start ) * 1000.0
221+ duration_ms = ( request_end - request_start ) * 1000.0
222222
223223 http_response = HTTPResponse . new (
224224 body : event_body ,
0 commit comments