Skip to content

Commit

Permalink
Merge pull request #62 from palazzem/rails-without-ar
Browse files Browse the repository at this point in the history
[rails] avoid conditional require for active_record contrib module
  • Loading branch information
Emanuele Palazzetti authored Jan 19, 2017
2 parents a2547f7 + 2e8dc0b commit 013165b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/ddtrace/contrib/rails/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/ddtrace/contrib/rails/framework.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 013165b

Please sign in to comment.