Module: RaceGuard::Interceptors::NetHttpRequest::RequestEmit

Defined in:
lib/race_guard/interceptors/net_http.rb

Class Method Summary collapse

Class Method Details

.call(http, req) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/race_guard/interceptors/net_http.rb', line 12

def call(http, req)
  host = http.instance_variable_get(:@address) if http.instance_variable_defined?(:@address)
  port = http.instance_variable_get(:@port) if http.instance_variable_defined?(:@port)
  method = req.respond_to?(:method) ? req.method : 'UNKNOWN'
  path = req.respond_to?(:path) ? req.path : req.class.name
  Emitter.emit(
    :net_http,
    "Net::HTTP #{method} #{host}:#{port}#{path}",
    'http_method' => method.to_s,
    'host' => host.to_s,
    'port' => port.to_s,
    'path' => path.to_s
  )
end