Module: CanaryIpa::NetHttpExtensions

Included in:
Net::HTTP
Defined in:
lib/canary_ipa.rb

Constant Summary collapse

@@sock =
UDPSocket.new
@@host =
ENV["CANARY_MONITORING_AGENT_HOST"] || "127.0.0.1"
@@port =
(ENV["CANARY_MONITORING_AGENT_PORT"] || "51712").to_i

Instance Method Summary collapse

Instance Method Details

#request(req, body = nil, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/canary_ipa.rb', line 9

def request(req, body = nil, &block)
  start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  result = super(req, body, &block)
  delta = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
  delta_ms = delta * 1000
  @@sock.send("0\t#{req.method}\t#{@address}\t#{req.path}\t#{delta_ms}\n", 0, @@host, @@port)
  #overhead = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start - delta
  #puts "Measuring and UDP overhead: around #{overhead}s"
  result
end