Skip to content

Commit 18cd634

Browse files
committed
Fix initialization proccess of the query tags
The tags were being added in the wrong way, now it is always using the configuration.
1 parent 1624246 commit 18cd634

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

actionpack/lib/action_controller/railtie.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,19 @@ class Railtie < Rails::Railtie # :nodoc:
9292
end
9393

9494
initializer "action_controller.query_log_tags" do |app|
95-
ActiveSupport.on_load(:active_record) do
96-
if app.config.active_record.query_log_tags_enabled && app.config.action_controller.log_query_tags_around_actions != false
95+
if app.config.active_record.query_log_tags_enabled && app.config.action_controller.log_query_tags_around_actions != false
96+
app.config.active_record.query_log_tags += [:controller, :action]
97+
98+
ActiveSupport.on_load(:action_controller) do
99+
include ActionController::QueryTags
100+
end
101+
102+
ActiveSupport.on_load(:active_record) do
97103
ActiveRecord::QueryLogs.taggings.merge!(
98104
controller: -> { context[:controller]&.controller_name },
99105
action: -> { context[:controller]&.action_name },
100106
namespaced_controller: -> { context[:controller]&.class&.name }
101107
)
102-
103-
ActiveRecord::QueryLogs.tags + [:controller, :action]
104-
105-
ActiveSupport.on_load(:action_controller) do
106-
include ActionController::QueryTags
107-
end
108108
end
109109
end
110110
end

activejob/lib/active_job/railtie.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,15 @@ class Railtie < Rails::Railtie # :nodoc:
5555
end
5656

5757
initializer "active_job.query_log_tags" do |app|
58+
if app.config.active_record.query_log_tags_enabled && app.config.active_job.log_query_tags_around_perform != false
59+
app.config.active_record.query_log_tags << :job
60+
61+
ActiveSupport.on_load(:active_job) do
62+
include ActiveJob::QueryTags
63+
end
64+
5865
ActiveSupport.on_load(:active_record) do
59-
if app.config.active_record.query_log_tags_enabled && app.config.active_job.log_query_tags_around_perform != false
6066
ActiveRecord::QueryLogs.taggings[:job] = -> { context[:job]&.class&.name }
61-
ActiveRecord::QueryLogs.tags << :job
62-
63-
ActiveSupport.on_load(:active_job) do
64-
include ActiveJob::QueryTags
65-
end
6667
end
6768
end
6869
end

0 commit comments

Comments
 (0)