Module: Raygun::Apm::Hooks::Excon

Defined in:
lib/raygun/apm/hooks/excon.rb

Instance Method Summary collapse

Instance Method Details

#request(params = {}, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/raygun/apm/hooks/excon.rb', line 7

def request(params={}, &block)
  if tracer = Raygun::Apm::Tracer.instance
    started = tracer.now
    response = super
    ended = tracer.now
    event = raygun_apm_http_out_event
    event[:pid] = Process.pid
    event[:url] = "#{@data[:scheme]}://#{@data[:host]}/#{params[:path]}"
    event[:verb] = params[:method].to_s.upcase
    event[:status] = response.status
    event[:duration] = ended - started
    event[:timestamp] = started
    event[:tid] = tracer.get_thread_id(Thread.current)
    tracer.emit(event)
    response
  else
    super
  end
end