Sha256: f7782e1cfae80a0cad8efb27d6b5d57a99f5d9c42d9ad71ba813d817951b9a39
Contents?: true
Size: 1.53 KB
Versions: 3
Compression:
Stored size: 1.53 KB
Contents
if defined?(Ethon) require 'uri' module Ethon class Easy module Http alias_method :orig_http_request, :http_request def http_request(url, action_name, options = {}) @binnacle_request_headers = options[:headers] @binnacle_backup_url = url @binnacle_action_name = action_name # remember this for compact logging @binnacle_request_headers = options[:headers] @binnacle_request_data = options[:body] orig_http_request(url, action_name, options) end end module Operations alias_method :orig_perform, :perform def perform _url = _url || @url || @binnacle_backup_url return orig_perform unless Binnacle::HttpLogger.allow?(_url) _response_code = nil bm = Benchmark.realtime do _response_code = orig_perform end uri = URI(_url) status = response_headers.scan(/HTTP\/... (\d{3})/).flatten.first encoding = response_headers.scan(/Content-Encoding: (\S+)/).flatten.first content_type = response_headers.scan(/Content-Type: (\S+(; charset=\S+)?)/).flatten.first url_without_query = "#{uri.scheme}://#{uri.host}:#{uri.port}#{uri.path}" Binnacle::HttpLogger.signal(url_without_query, @binnacle_action_name, uri.host, uri.port, uri.path, uri.query, response_code, bm, @binnacle_request_headers, response_body, encoding, content_type, @binnacle_request_data) return_code end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
binnacle-0.5.0 | lib/binnacle/http_logging/adapters/ethon.rb |
binnacle-0.4.9 | lib/binnacle/http_logging/adapters/ethon.rb |
binnacle-0.4.8 | lib/binnacle/http_logging/adapters/ethon.rb |