Module: RPMContrib::Instrumentation::MongoMapper

Defined in:
lib/rpm_contrib/instrumentation/mongo_mapper.rb

Overview

Just drop this little diddy in your app to get some (not perfect) information on query times and such.

Currently only MongoMapper is implemented

Class Method Summary collapse

Class Method Details

.included(model) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rpm_contrib/instrumentation/mongo_mapper.rb', line 9

def self.included(model)
  model.class_eval do
    class << self
      add_method_tracer :find,        'Database/#{self.name}/find'
      add_method_tracer :find!,       'Database/#{self.name}/find!'
      add_method_tracer :paginate,    'Database/#{self.name}/paginate'
      add_method_tracer :first,       'Database/#{self.name}/first'
      add_method_tracer :last,        'Database/#{self.name}/last'
      add_method_tracer :all,         'Database/#{self.name}/all'
      add_method_tracer :count,       'Database/#{self.name}/count'
      add_method_tracer :create,      'Database/#{self.name}/create'
      add_method_tracer :create!,     'Database/#{self.name}/create!'
      add_method_tracer :update,      'Database/#{self.name}/update'
      add_method_tracer :delete,      'Database/#{self.name}/delete'
      add_method_tracer :delete_all,  'Database/#{self.name}/delete_all'
      add_method_tracer :destroy,     'Database/#{self.name}/destroy'
      add_method_tracer :destroy_all, 'Database/#{self.name}/destroy_all'
      add_method_tracer :exists?,     'Database/#{self.name}/exists?'
      add_method_tracer :find_by_id,  'Database/#{self.name}/find_by_id'
      add_method_tracer :increment,   'Database/#{self.name}/increment'
      add_method_tracer :decrement,   'Database/#{self.name}/decrement'
      add_method_tracer :set,         'Database/#{self.name}/set'
      add_method_tracer :push,        'Database/#{self.name}/push'
      add_method_tracer :push_all,    'Database/#{self.name}/push_all'
      add_method_tracer :push_uniq,   'Database/#{self.name}/push_uniq'
      add_method_tracer :pull,        'Database/#{self.name}/pull'
      add_method_tracer :pull_all,    'Database/#{self.name}/pull_all'
    end

    add_method_tracer :save, 'Database/#{self.class.name}/save'
  end
end