Module: NewRelic::Security::Instrumentation::Mongo::Collection

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

Defined Under Namespace

Modules: Chain, Prepend, View

Instance Method Summary collapse

Instance Method Details

#find_on_enter(filter, options) ⇒ Object



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

def find_on_enter(filter, options)
  event = nil
  NewRelic::Security::Agent.logger.debug "OnEnter : #{self.class}.#{__method__}"
  hash = {}
  hash[:payload] = {}
  hash[:payload][:filter] = filter
  hash[:payload][:options] = options
  hash[:payloadType] = :find #bind params
  event = NewRelic::Security::Agent::Control::Collector.collect(NOSQL_DB_COMMAND, [hash], MONGO)
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
  return event
end

#find_on_exit(event) ⇒ Object



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

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

#insert_many_on_enter(documents, options) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/newrelic_security/instrumentation-security/mongo/instrumentation.rb', line 62

def insert_many_on_enter(documents, options)
  event = nil
  NewRelic::Security::Agent.logger.debug "OnEnter : #{self.class}.#{__method__}"
  hash = {}
  hash[:payload] = {}
  hash[:payload][:documents] = documents
  hash[:payload][:options] = options
  hash[:payloadType] = :insert
  event = NewRelic::Security::Agent::Control::Collector.collect(NOSQL_DB_COMMAND, [hash], MONGO)
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
  return event
end

#insert_many_on_exit(event) ⇒ Object



78
79
80
81
82
83
84
85
# File 'lib/newrelic_security/instrumentation-security/mongo/instrumentation.rb', line 78

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

#insert_one_on_enter(document, opts) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/newrelic_security/instrumentation-security/mongo/instrumentation.rb', line 33

def insert_one_on_enter(document, opts)
  event = nil
  NewRelic::Security::Agent.logger.debug "OnEnter : #{self.class}.#{__method__}"
  if caller_locations[1].label.to_s == "insert_one_with_clear_cache"
    NewRelic::Security::Agent.logger.debug "Filtered to break the loop calling #{self.class}.#{__method__} from 'insert_one_with_clear_cache'"
    return
  end
  hash = {}
  hash[:payload] = {}
  hash[:payload][:document] = document
  hash[:payload][:opts] = opts
  hash[:payloadType] = :insert
  event = NewRelic::Security::Agent::Control::Collector.collect(NOSQL_DB_COMMAND, [hash], MONGO)
rescue => exception
  NewRelic::Security::Agent.logger.error "Exception in hook in #{self.class}.#{__method__}, #{exception.inspect}, #{exception.backtrace}"
ensure
  yield
  return event
end

#insert_one_on_exit(event) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/newrelic_security/instrumentation-security/mongo/instrumentation.rb', line 53

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