diff --git a/lib/ddtrace/contrib/rails/active_record.rb b/lib/ddtrace/contrib/rails/active_record.rb index d2edba777c..4281d4ce58 100644 --- a/lib/ddtrace/contrib/rails/active_record.rb +++ b/lib/ddtrace/contrib/rails/active_record.rb @@ -8,6 +8,9 @@ module Rails # TODO[manu]: write docs module ActiveRecord def self.instrument + # ActiveRecord is instrumented only if it's available + return unless defined?(::ActiveRecord) + # subscribe when the active record query has been processed ::ActiveSupport::Notifications.subscribe('sql.active_record') do |*args| sql(*args) diff --git a/lib/ddtrace/contrib/rails/framework.rb b/lib/ddtrace/contrib/rails/framework.rb index 2afe9178fc..fdd866b4ce 100644 --- a/lib/ddtrace/contrib/rails/framework.rb +++ b/lib/ddtrace/contrib/rails/framework.rb @@ -4,7 +4,7 @@ require 'ddtrace/contrib/rails/core_extensions' require 'ddtrace/contrib/rails/action_controller' require 'ddtrace/contrib/rails/action_view' -require 'ddtrace/contrib/rails/active_record' if defined?(::ActiveRecord) +require 'ddtrace/contrib/rails/active_record' require 'ddtrace/contrib/rails/active_support' require 'ddtrace/contrib/rails/utils' @@ -102,7 +102,7 @@ def self.auto_instrument # instrumenting Rails framework Datadog::Contrib::Rails::ActionController.instrument() Datadog::Contrib::Rails::ActionView.instrument() - Datadog::Contrib::Rails::ActiveRecord.instrument() if defined?(::ActiveRecord) + Datadog::Contrib::Rails::ActiveRecord.instrument() Datadog::Contrib::Rails::ActiveSupport.instrument() # by default, Rails 3 doesn't instrument the cache system