Class: ScoutApm::Instruments::ActionControllerRails2

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ ActionControllerRails2

Returns a new instance of ActionControllerRails2.



6
7
8
9
# File 'lib/scout_apm/instruments/action_controller_rails_2.rb', line 6

def initialize(context)
  @context = context
  @installed = false
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



4
5
6
# File 'lib/scout_apm/instruments/action_controller_rails_2.rb', line 4

def context
  @context
end

Instance Method Details

#installObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/scout_apm/instruments/action_controller_rails_2.rb', line 19

def install
  if defined?(::ActionController) && defined?(::ActionController::Base)
    @installed = true

    ::ActionController::Base.class_eval do
      include ScoutApm::Tracer
      include ::ScoutApm::Instruments::ActionControllerRails2Instruments
    end

    logger.info "Instrumenting ActionView::Template"
    ::ActionView::Template.class_eval do
      include ::ScoutApm::Tracer
      instrument_method :render, :type => "View", :name => '#{path[%r{^(/.*/)?(.*)$},2]}/Rendering', :scope => true
    end
  end

end

#installed?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/scout_apm/instruments/action_controller_rails_2.rb', line 15

def installed?
  @installed
end

#loggerObject



11
12
13
# File 'lib/scout_apm/instruments/action_controller_rails_2.rb', line 11

def logger
  context.logger
end