Permalink
Browse files

Display the duration of http requests in the debug output

  • Loading branch information...
1 parent 3feb7eb commit 706e42f5c5a2dc7b3e0bb7389f26f64514a111de @smarterclayton smarterclayton committed Mar 18, 2013
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/rhc/rest/client.rb
View
@@ -3,6 +3,7 @@
require 'uri'
require 'logger'
require 'httpclient'
+require 'benchmark'
module RHC
module Rest
@@ -247,10 +248,11 @@ def request(options, &block)
begin
client, args = new_request(options.dup)
auth = options[:auth] || self.auth
+ response = nil
debug "Request #{args[0].to_s.upcase} #{args[1]}" if debug?
- response = client.request(*(args << true))
- debug " code #{response.status}" if debug? && response
+ time = Benchmark.realtime{ response = client.request(*(args << true)) }
+ debug " code %s %4i ms" % [response.status, (time*1000).to_i] if debug? && response
next if retry_proxy(response, i, args, client)
auth.retry_auth?(response, self) and next if auth

0 comments on commit 706e42f

Please sign in to comment.