summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2016-02-09 17:04:53 +0100
committerJacob Vosmaer <contact@jacobvosmaer.nl>2016-02-09 17:04:53 +0100
commit08c8f3085f414c669fd105e4494e2400c03146dc (patch)
tree1f135c7e2e407949f7ed2c8429b543656af5fdfd
parente07469ff7bf3b65908fa2aeb572b56974133b25a (diff)
downloadgitlab-shell-net-read-timeout.tar.gz
Log duration of HTTP API requestsnet-read-timeout
-rw-r--r--lib/gitlab_net.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/gitlab_net.rb b/lib/gitlab_net.rb
index 5d0148e..4377005 100644
--- a/lib/gitlab_net.rb
+++ b/lib/gitlab_net.rb
@@ -106,10 +106,15 @@ class GitlabNet
request = http_request_for(method, uri, params)
begin
+ start_time = Time.new
response = http.start { http.request(request) }
rescue => e
$logger.warn "Failed to connect to internal API <#{method.to_s.upcase} #{url}>: #{e.inspect}"
raise ApiUnreachableError
+ ensure
+ $logger.info do
+ sprintf('%s %s %0.5f', method.to_s.upcase, url, Time.new - start_time)
+ end
end
if response.code == "200"