Module: RPMContrib::Instrumentation::Mongoid

Included in:
Mongoid::Document
Defined in:
lib/rpm_contrib/instrumentation/mongoid.rb

Instance Method Summary collapse

Instance Method Details

#included(model) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rpm_contrib/instrumentation/mongoid.rb', line 21

def included(model)
  model.class_eval do
    class << self
      add_method_tracer :create, 'Database/#{self.name}/create'
      add_method_tracer :create!, 'Database/#{self.name}/create!'
      add_method_tracer :delete_all, 'Database/#{self.name}/delete_all'
      add_method_tracer :destroy_all, 'Database/#{self.name}/destroy_all'
      add_method_tracer :all, 'Database/#{self.name}/all'
      add_method_tracer :find, 'Database/#{self.name}/find'
      add_method_tracer :first, 'Database/#{self.name}/first'
      add_method_tracer :last, 'Database/#{self.name}/last'
      add_method_tracer :find_or_create_by, 'Database/#{self.name}/find_or_create_by'
      add_method_tracer :find_or_initialize_by, 'Database/#{self.name}/find_or_initialize_by'
      add_method_tracer :min, 'Database/#{self.name}/min'
      add_method_tracer :max, 'Database/#{self.name}/max'
      add_method_tracer :sum, 'Database/#{self.name}/sum'
    end

    add_method_tracer :update_attributes, 'Database/#{self.class.name}/update_attributes'
    add_method_tracer :update_attributes!, 'Database/#{self.class.name}/update_attributes!'
    add_method_tracer :save, 'Database/#{self.class.name}/save'
    add_method_tracer :save!, 'Database/#{self.class.name}/save!'
    add_method_tracer :delete, 'Database/#{self.class.name}/delete'
    add_method_tracer :destroy, 'Database/#{self.class.name}/destroy'
  end
  super
end