Fix initialization proccess of the query tags

The tags were being added in the wrong way, now it is always using the
configuration.
This commit is contained in:
Rafael Mendonça França 2021-08-17 22:59:44 +00:00
parent 16242464db
commit 18cd634e07
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948
2 changed files with 16 additions and 15 deletions

View File

@ -92,19 +92,19 @@ module ActionController
end
initializer "action_controller.query_log_tags" do |app|
ActiveSupport.on_load(:active_record) do
if app.config.active_record.query_log_tags_enabled && app.config.action_controller.log_query_tags_around_actions != false
if app.config.active_record.query_log_tags_enabled && app.config.action_controller.log_query_tags_around_actions != false
app.config.active_record.query_log_tags += [:controller, :action]
ActiveSupport.on_load(:action_controller) do
include ActionController::QueryTags
end
ActiveSupport.on_load(:active_record) do
ActiveRecord::QueryLogs.taggings.merge!(
controller: -> { context[:controller]&.controller_name },
action: -> { context[:controller]&.action_name },
namespaced_controller: -> { context[:controller]&.class&.name }
)
ActiveRecord::QueryLogs.tags + [:controller, :action]
ActiveSupport.on_load(:action_controller) do
include ActionController::QueryTags
end
end
end
end

View File

@ -55,14 +55,15 @@ module ActiveJob
end
initializer "active_job.query_log_tags" do |app|
ActiveSupport.on_load(:active_record) do
if app.config.active_record.query_log_tags_enabled && app.config.active_job.log_query_tags_around_perform != false
ActiveRecord::QueryLogs.taggings[:job] = -> { context[:job]&.class&.name }
ActiveRecord::QueryLogs.tags << :job
if app.config.active_record.query_log_tags_enabled && app.config.active_job.log_query_tags_around_perform != false
app.config.active_record.query_log_tags << :job
ActiveSupport.on_load(:active_job) do
include ActiveJob::QueryTags
end
ActiveSupport.on_load(:active_job) do
include ActiveJob::QueryTags
end
ActiveSupport.on_load(:active_record) do
ActiveRecord::QueryLogs.taggings[:job] = -> { context[:job]&.class&.name }
end
end
end