Module: NewRelic::Security::Instrumentation::Patron::Session

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

Defined Under Namespace

Modules: Chain, Prepend

Instance Method Summary collapse

Instance Method Details

#request_on_enter(_action, url, headers, _options) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/newrelic_security/instrumentation-security/patron/instrumentation.rb', line 10

def request_on_enter(_action, url, headers, _options)
  event = nil
  NewRelic::Security::Agent.logger.debug "OnEnter : #{self.class}.#{__method__}"
  final_url = self.base_url.nil? ? url : "#{self.base_url}#{url}"
  uri = NewRelic::Security::Instrumentation::InstrumentationUtils.parse_uri(final_url)
  event = NewRelic::Security::Agent::Control::Collector.collect(HTTP_REQUEST, [uri.to_s]) if uri
  NewRelic::Security::Instrumentation::InstrumentationUtils.add_tracing_data(headers, 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

#request_on_exit(event) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/newrelic_security/instrumentation-security/patron/instrumentation.rb', line 25

def 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