Skip to content

Add ActiveSupport::ExecutionContext controller setting for Rails 7+#190

Open
Blayr wants to merge 1 commit intoshadabahmed:mainfrom
Blayr:feature/execution-context-rails-7
Open

Add ActiveSupport::ExecutionContext controller setting for Rails 7+#190
Blayr wants to merge 1 commit intoshadabahmed:mainfrom
Blayr:feature/execution-context-rails-7

Conversation

@Blayr
Copy link
Copy Markdown

@Blayr Blayr commented Mar 6, 2026

This adds missing ActiveSupport::ExecutionContext used by ActiveRecord QueryLogs
https://api.rubyonrails.org/classes/ActiveRecord/QueryLogs.html

Link to the introduction of this behaviour in Rails/ActionPack (Rails 7.0):
https://github.com/rails/rails/blob/984c3ef2775781d47efa9f541ce570daa2434a80/actionpack/lib/action_controller/metal/instrumentation.rb#L51

Before this change, having

# application.rb (rails app)
config.active_record.query_log_tags_enabled = true
config.active_record.query_log_tags = [ :application, :controller, :action, :job ]

would not yield :controller or :action when the log was being generated

Before

SELECT `users`.`id` FROM `users` WHERE `users`.`id` = 1
/*application=someapp*/

After changes in this PR:

SELECT `users`.`id` FROM `users` WHERE `users`.`id` = 1
/*application=someapp,action='index',controller='users'*/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant