Class: Excon::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/http_event_logger/adapter/excon.rb

Instance Method Summary collapse

Instance Method Details

#request_with_logging(params, &block) ⇒ Object


18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/http_event_logger/adapter/excon.rb', line 18

def request_with_logging(params, &block)
  request_datum = @data.merge(params)
  request_datum[:headers] = @data[:headers].merge(request_datum[:headers] || {})
  request_event = create_request_event(request_datum)
  result = nil
  time_taken_in_seconds = ::Benchmark.realtime do
    result = request_without_logging(params, &block)
  end
  response = result.is_a?(Excon::Response) ? result : Excon::Response.new(response(result)[:response])
  create_response_event(request_event, time_taken_in_seconds, response)
  result
end