class Sqreen::Ecosystem::Http::NetHttp

Public Instance Methods

setup() click to toggle source
# File lib/sqreen/ecosystem/http/net_http.rb, line 24
def setup
  advice = wrap_for_interest(HttpConnectionData, &method(:before_advice))
  instrument 'Net::HTTP#request', before: advice
end

Private Instance Methods

before_advice(call, _ball) click to toggle source

instr. def request(req, body = nil, &block) # :yield: response req is of type Net::HTTPGenericRequest

# File lib/sqreen/ecosystem/http/net_http.rb, line 33
def before_advice(call, _ball)
  tracing_id = create_tracing_id

  # build & submit signal
  host = call.instance.address
  port = call.instance.port

  # add tracing header
  req = call.args[0]
  req[ModuleApi::TRACE_ID_HEADER] = tracing_id

  host += ':' + port.to_s if port != 80 && port != 443

  HttpConnectionData.new(
    transport: 'http',
    host: host,
    tracing_identifier: tracing_id
  )
end