Skip to content

Commit 5e7d425

Browse files
committed
TPCF-27209 - CAPI logs should for request complete should include the response time
Add time taken to json based on code review comments
1 parent a7d79f7 commit 5e7d425

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/cloud_controller/logs/request_logs.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ def start_request(request_id, env)
2929
def complete_request(request_id, status, env, time_taken)
3030
return if @incomplete_requests.delete(request_id).nil?
3131
request = ActionDispatch::Request.new(env)
32-
@logger.info("Completed #{status} vcap-request-id: #{request_id} Response Time: #{time_taken}",
32+
@logger.info("Completed #{status} vcap-request-id: #{request_id}",
3333
{ status_code: status,
34-
request_method: request.request_method,
35-
request_fullpath: request.filtered_path })
34+
time_taken: time_taken,
35+
request_method: request.request_method,
36+
request_fullpath: request.filtered_path })
3637
end
3738

3839
def log_incomplete_requests

spec/unit/lib/cloud_controller/logs/request_logs_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module VCAP::CloudController::Logs
4747

4848
it 'logs the completion of the request' do
4949
request_logs.complete_request(request_id, status, env, time_taken)
50-
expect(logger).to have_received(:info).with(/Completed 200 vcap-request-id: ID Response Time: 30/, { request_method: "request_method", request_fullpath: "filtered_path", status_code: 200 })
50+
expect(logger).to have_received(:info).with(/Completed 200 vcap-request-id: ID/, { time_taken: 30, request_method: "request_method", request_fullpath: "filtered_path", status_code: 200 })
5151
end
5252
end
5353

0 commit comments

Comments
 (0)