dd-trace-rb
dd-trace-rb copied to clipboard
Add Rails component configuration
This PR depends on #809.
As a follow-up to #450 and #764, this pull request adds block style configuration for Rails components available, to make configuration more expressive and customizable.
Some new configuration examples include:
# Customize ActiveRecord with block
Datadog.configure do |c|
c.use :rails do |rails|
rails.service_name = 'my-app'
rails.active_record do |active_record|
active_record.service_name = "#{rails.service_name}-postgres"
end
end
end
# Customize different ActiveRecord databases with block
Datadog.configure do |c|
c.use :rails do |rails|
rails.service_name = 'my-app'
rails.active_record describes: :primary_db do |active_record|
active_record.service_name = "#{rails.service_name}-primary-db"
end
rails.active_record describes: :secondary_db do |active_record|
active_record.service_name = "#{rails.service_name}-secondary-db"
end
end
end
# Deactivate ActiveRecord
Datadog.configure do |c|
c.use :rails do |rails|
rails.active_record false
end
end
The Rails configuration now allows all its sub-integrations (rack, active_record, action_view, action_pack, active_support
) and their constituent options to configured in this manner.