Class: ScoutApm::Instruments::ActionControllerRails3Rails4

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/instruments/action_controller_rails_3_rails4.rb

Overview

instrumentation for Rails 3 and Rails 4 is the same.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



5
6
7
# File 'lib/scout_apm/instruments/action_controller_rails_3_rails4.rb', line 5

def logger
  @logger
end

Instance Method Details

#initalize(logger = ScoutApm::Agent.instance.logger) ⇒ Object



7
8
9
10
# File 'lib/scout_apm/instruments/action_controller_rails_3_rails4.rb', line 7

def initalize(logger=ScoutApm::Agent.instance.logger)
  @logger = logger
  @installed = false
end

#installObject



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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/scout_apm/instruments/action_controller_rails_3_rails4.rb', line 16

def install
  @installed = true

  # We previously instrumented ActionController::Metal, which missed
  # before and after filter timing. Instrumenting Base includes those
  # filters, at the expense of missing out on controllers that don't use
  # the full Rails stack.
  if defined?(::ActionController) && defined?(::ActionController::Base)
    ScoutApm::Agent.instance.logger.info "Instrumenting ActionController::Base"
    ::ActionController::Base.class_eval do
      # include ScoutApm::Tracer
      include ScoutApm::Instruments::ActionControllerRails3Rails4Instruments
    end
  end

  if defined?(::ActionView) && defined?(::ActionView::PartialRenderer)
    ScoutApm::Agent.instance.logger.info "Instrumenting ActionView::PartialRenderer"
    ::ActionView::PartialRenderer.class_eval do
      include ScoutApm::Tracer

      instrument_method :render_partial,
        :type => "View",
        :name => '#{@template.virtual_path rescue "Unknown Partial"}/Rendering',
        :scope => true

      instrument_method :collection_with_template,
        :type => "View",
        :name => '#{@template.virtual_path rescue "Unknown Collection"}/Rendering',
        :scope => true
    end

    ScoutApm::Agent.instance.logger.info "Instrumenting ActionView::TemplateRenderer"
    ::ActionView::TemplateRenderer.class_eval do
      include ScoutApm::Tracer
      instrument_method :render_template,
        :type => "View",
        :name => '#{args[0].virtual_path rescue "Unknown"}/Rendering',
        :scope => true
    end
  end
end

#installed?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/scout_apm/instruments/action_controller_rails_3_rails4.rb', line 12

def installed?
  @installed
end