Class: ScoutApm::Instruments::ActiveRecord
- Inherits:
-
Object
- Object
- ScoutApm::Instruments::ActiveRecord
- Defined in:
- lib/scout_apm/instruments/active_record.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #add_instruments ⇒ Object
- #initalize(logger = ScoutApm::Agent.instance.logger) ⇒ Object
- #install ⇒ Object
- #installed? ⇒ Boolean
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/scout_apm/instruments/active_record.rb', line 6 def logger @logger end |
Instance Method Details
#add_instruments ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/scout_apm/instruments/active_record.rb', line 29 def add_instruments if defined?(::ActiveRecord) && defined?(::ActiveRecord::Base) ::ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do include ::ScoutApm::Instruments::ActiveRecordInstruments include ::ScoutApm::Tracer end ::ActiveRecord::Base.class_eval do include ::ScoutApm::Tracer end end rescue ScoutApm::Agent.instance.logger.warn "ActiveRecord instrumentation exception: #{$!.}" end |
#initalize(logger = ScoutApm::Agent.instance.logger) ⇒ Object
8 9 10 11 |
# File 'lib/scout_apm/instruments/active_record.rb', line 8 def initalize(logger=ScoutApm::Agent.instance.logger) @logger = logger @installed = false end |
#install ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/scout_apm/instruments/active_record.rb', line 17 def install @installed = true if defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 3 && ::Rails.respond_to?(:configuration) Rails.configuration.after_initialize do add_instruments end else add_instruments end end |
#installed? ⇒ Boolean
13 14 15 |
# File 'lib/scout_apm/instruments/active_record.rb', line 13 def installed? @installed end |