The Apartment gem helps Rails applications achieve database multitenancy. There is a known incompatiability with New Relic and Apartment when the config setting active_record_log = true is present. This config unsubscribes from ActiveRecord notifications, which Ruby agent instrumentation relies on. We are unable to provide insights into ActiveRecord calls when that config setting is enabled, which it isn't by default.
config.after_initialize do
# NOTE: Load the custom log subscriber if enabled
if Apartment.active_record_log
ActiveSupport::Notifications.notifier.listeners_for('sql.active_record').each do |listener|
next unless listener.instance_variable_get('@delegate').is_a?(ActiveRecord::LogSubscriber)
ActiveSupport::Notifications.unsubscribe listener
end
Apartment::LogSubscriber.attach_to :active_record
end
end
Customers can disable this configuration value and recieve New Relic insights into their database calls.
Acceptance Criteria
We should understand why this configuration setting needs to disable ActiveRecord notifications, and from there decide if we add our findings to a troubleshooting guide that instructs turning off this config setting for New Relic to report database calls, or programatically work around this issue in the agent.
Post-completion
The GTSE team created a KCS article describing the fix of removing the config. Whatever we decided to do with this ticket, we should update teh GTSE team so they can edit that article if needed.
Description
The Apartment gem helps Rails applications achieve database multitenancy. There is a known incompatiability with New Relic and Apartment when the config setting
active_record_log = true
is present. This config unsubscribes from ActiveRecord notifications, which Ruby agent instrumentation relies on. We are unable to provide insights into ActiveRecord calls when that config setting is enabled, which it isn't by default.Customers can disable this configuration value and recieve New Relic insights into their database calls.
Acceptance Criteria
We should understand why this configuration setting needs to disable ActiveRecord notifications, and from there decide if we add our findings to a troubleshooting guide that instructs turning off this config setting for New Relic to report database calls, or programatically work around this issue in the agent.
Post-completion
The GTSE team created a KCS article describing the fix of removing the config. Whatever we decided to do with this ticket, we should update teh GTSE team so they can edit that article if needed.