Module: NewRelic::Security::Instrumentation::Mysql2::Statement

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

Defined Under Namespace

Modules: Chain, Prepend

Instance Method Summary collapse

Instance Method Details

#execute_on_enter(*args, **kwargs) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/newrelic_security/instrumentation-security/mysql2/instrumentation.rb', line 54

def execute_on_enter(*args, **kwargs)
  event = nil
  NewRelic::Security::Agent.logger.debug "OnEnter : #{self.class}.#{__method__}"
  hash = {}
  hash[:sql] = NewRelic::Security::Agent::Control::HTTPContext.get_context.cache[self.object_id] if NewRelic::Security::Agent::Control::HTTPContext.get_context
  hash[:parameters] = args.map(&:to_s)
  event = NewRelic::Security::Agent::Control::Collector.collect(SQL_DB_COMMAND, [hash], MYSQL) unless NewRelic::Security::Instrumentation::InstrumentationUtils.sql_filter_events?(hash[:sql])
  NewRelic::Security::Agent::Control::HTTPContext.get_context.cache.delete(self.object_id) if NewRelic::Security::Agent::Control::HTTPContext.get_context
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
  return event
end

#execute_on_exit(event) ⇒ Object



69
70
71
72
73
74
75
76
# File 'lib/newrelic_security/instrumentation-security/mysql2/instrumentation.rb', line 69

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