Module: NewRelic::Security::Instrumentation::Ethon::Multi

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

Defined Under Namespace

Modules: Chain, Prepend

Instance Method Summary collapse

Instance Method Details

#perform_on_enter(*_args) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/newrelic_security/instrumentation-security/ethon/instrumentation.rb', line 49

def perform_on_enter(*_args)
  event = nil
  NewRelic::Security::Agent.logger.debug "OnEnter : #{self.class}.#{__method__}"
  ic_args = []
  easy_handles.each do |easy|
    uri = NewRelic::Security::Instrumentation::InstrumentationUtils.parse_uri(easy.url)
    ic_args << easy.url.to_s if uri
  end
  event = NewRelic::Security::Agent::Control::Collector.collect(HTTP_REQUEST, ic_args) unless ic_args.empty?
  easy_handles.each do |easy|
    context = NewRelic::Security::Agent::Control::HTTPContext.get_context.cache[easy.object_id] if NewRelic::Security::Agent::Control::HTTPContext.get_context
    headers_copy = {}
    headers_copy.merge!(context[:headers]) if context&.key?(:headers)
    NewRelic::Security::Instrumentation::InstrumentationUtils.add_tracing_data(headers_copy, event) if event
    easy.headers = headers_copy
  end
  event
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
  return event
end

#perform_on_exit(event) ⇒ Object



73
74
75
76
77
78
79
80
# File 'lib/newrelic_security/instrumentation-security/ethon/instrumentation.rb', line 73

def perform_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