class OpenTelemetry::Instrumentation::ActiveRecord::Instrumentation
The Instrumentation
class contains logic to detect and install the ActiveRecord
instrumentation
Constants
- MINIMUM_VERSION
Private Instance Methods
gem_version()
click to toggle source
# File lib/opentelemetry/instrumentation/active_record/instrumentation.rb, line 33 def gem_version Gem.loaded_specs['activerecord'].version end
insert_class_methods_supported?()
click to toggle source
# File lib/opentelemetry/instrumentation/active_record/instrumentation.rb, line 29 def insert_class_methods_supported? gem_version >= Gem::Version.new('6.0.0') end
patch()
click to toggle source
# File lib/opentelemetry/instrumentation/active_record/instrumentation.rb, line 37 def patch # The original approach taken here was to patch each individual module of interest. # However the patches are applied too late in some applications and as a result the # Active Record models will not have the instrumentation patches applied. # Prepending the ActiveRecord::Base class is more consistent in applying # the patches regardless of initialization order. # # Modules to prepend to ActiveRecord::Base are still grouped by the source # module that they are defined in. # Example: Patches::PersistenceClassMethods refers to https://github.com/rails/rails/blob/v6.1.0/activerecord/lib/active_record/persistence.rb#L10 ::ActiveRecord::Base.prepend(Patches::Querying) ::ActiveRecord::Base.prepend(Patches::Persistence) ::ActiveRecord::Base.prepend(Patches::PersistenceClassMethods) ::ActiveRecord::Base.prepend(Patches::PersistenceInsertClassMethods) if insert_class_methods_supported? ::ActiveRecord::Base.prepend(Patches::TransactionsClassMethods) ::ActiveRecord::Base.prepend(Patches::Validations) end
require_dependencies()
click to toggle source
# File lib/opentelemetry/instrumentation/active_record/instrumentation.rb, line 55 def require_dependencies require_relative 'patches/querying' require_relative 'patches/persistence' require_relative 'patches/persistence_class_methods' require_relative 'patches/persistence_insert_class_methods' if insert_class_methods_supported? require_relative 'patches/transactions_class_methods' require_relative 'patches/validations' end