Module: NewRelic::Security::Instrumentation::Mysql2::Client

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

#prepare_on_enter(sql) ⇒ Object



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

def prepare_on_enter(sql)
  event = nil
  NewRelic::Security::Agent.logger.debug "OnEnter : #{self.class}.#{__method__}"
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
  return event
end

#prepare_on_exit(event, retval, sql) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/newrelic_security/instrumentation-security/mysql2/instrumentation.rb', line 41

def prepare_on_exit(event, retval, sql)
  NewRelic::Security::Agent.logger.debug "OnExit :  #{self.class}.#{__method__}"
  NewRelic::Security::Agent::Control::HTTPContext.get_context.cache[retval.object_id] = sql 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
end

#query_on_enter(sql, options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/newrelic_security/instrumentation-security/mysql2/instrumentation.rb', line 8

def query_on_enter(sql, options)
  event = nil
  NewRelic::Security::Agent.logger.debug "OnEnter : #{self.class}.#{__method__}"
  hash = {}
  hash[:sql] = sql
  hash[:parameters] = []
  event = NewRelic::Security::Agent::Control::Collector.collect(SQL_DB_COMMAND, [hash], MYSQL) unless NewRelic::Security::Instrumentation::InstrumentationUtils.sql_filter_events?(hash[:sql])
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
  return event
end

#query_on_exit(event) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/newrelic_security/instrumentation-security/mysql2/instrumentation.rb', line 22

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