Module: NewRelic::Security::Instrumentation::Ethon::Easy

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

#headers_equals_on_enter(headers) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/newrelic_security/instrumentation-security/ethon/instrumentation.rb', line 10

def headers_equals_on_enter(headers)
  NewRelic::Security::Agent.logger.debug "OnEnter : #{self.class}.#{__method__}"
  NewRelic::Security::Agent::Control::HTTPContext.get_context.cache[object_id][:headers] = headers if NewRelic::Security::Agent::Control::HTTPContext.get_context && NewRelic::Security::Agent::Control::HTTPContext.get_context.cache[object_id]
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
end

#perform_on_enter(*_args) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/newrelic_security/instrumentation-security/ethon/instrumentation.rb', line 19

def perform_on_enter(*_args)
  event = nil
  NewRelic::Security::Agent.logger.debug "OnEnter : #{self.class}.#{__method__}"
  context = NewRelic::Security::Agent::Control::HTTPContext.get_context.cache[object_id] if NewRelic::Security::Agent::Control::HTTPContext.get_context
  uri = ::URI.parse(url)
  event = NewRelic::Security::Agent::Control::Collector.collect(HTTP_REQUEST, [uri.to_s])
  headers_copy = {}
  headers_copy.merge!(context[:headers]) if context&.key?(:headers)
  NewRelic::Security::Instrumentation::InstrumentationUtils.add_tracing_data(headers_copy, event) if event
  self.headers = headers_copy if headers 
  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



37
38
39
40
41
42
43
44
# File 'lib/newrelic_security/instrumentation-security/ethon/instrumentation.rb', line 37

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