Module: DebugAgent::OutboundHttpTracker

Defined in:
lib/debug_agent/inspectors/http_client.rb

Overview

Prepended module that instruments Net::HTTP request lifecycle.

Instance Method Summary collapse

Instance Method Details

#finishObject



69
70
71
72
# File 'lib/debug_agent/inspectors/http_client.rb', line 69

def finish
  DebugAgent.track_http_disconnect(self) rescue nil
  super
end

#request(req, *args, &block) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/debug_agent/inspectors/http_client.rb', line 74

def request(req, *args, &block)
  started = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  begin
    result = super
    elapsed = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - started) * 1000.0)
    DebugAgent.record_outbound(self, req, elapsed, nil) rescue nil
    result
  rescue => e
    elapsed = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - started) * 1000.0)
    DebugAgent.record_outbound(self, req, elapsed, e) rescue nil
    raise
  end
end

#startObject



64
65
66
67
# File 'lib/debug_agent/inspectors/http_client.rb', line 64

def start
  DebugAgent.track_http_connect(self) rescue nil
  super
end