Module: NewRelic::Security::Instrumentation::NetHTTP

Included in:
Prepend
Defined in:
lib/newrelic_security/instrumentation-security/net_http/chain.rb,
lib/newrelic_security/instrumentation-security/net_http/prepend.rb,
lib/newrelic_security/instrumentation-security/net_http/instrumentation.rb

Defined Under Namespace

Modules: Chain, Prepend

Constant Summary collapse

HTTP =
'http'
HTTP_COLON_SLASH_SLAH =
'http://'
HTTPS_COLON_SLASH_SLAH =
'https://'

Instance Method Summary collapse

Instance Method Details

#transport_request_on_enter(req) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/newrelic_security/instrumentation-security/net_http/instrumentation.rb', line 13

def transport_request_on_enter(req)
  event = nil
  NewRelic::Security::Agent.logger.debug "OnEnter : #{self.class}.#{__method__}"
				uri = if req.uri && URI === req.uri
    req.uri.to_s
    else
          "#{self.use_ssl? ? HTTPS_COLON_SLASH_SLAH : HTTP_COLON_SLASH_SLAH }#{self.address}:#{self.port}#{req.path}"
    end
  event = NewRelic::Security::Agent::Control::Collector.collect(HTTP_REQUEST, [uri])
  NewRelic::Security::Instrumentation::InstrumentationUtils.add_tracing_data(req, event) if event
  event
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
  return event
end

#transport_request_on_exit(event) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/newrelic_security/instrumentation-security/net_http/instrumentation.rb', line 31

def transport_request_on_exit(event)
  NewRelic::Security::Agent.logger.debug "OnExit :  #{self.class}.#{__method__}"
  NewRelic::Security::Agent::Utils.create_exit_event(event)
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
end