Skip to content

T-10657 Support Rails 8.2 where log subscribers moved to ActiveSupport::EventReporter - #55

Draft
PetrHeinz wants to merge 5 commits into
mainfrom
claude/t-10657-rails-edge
Draft

PetrHeinz wants to merge 5 commits into
mainfrom
claude/t-10657-rails-edge

Conversation

@PetrHeinz

@PetrHeinz PetrHeinz commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

On Rails main (8.2.0.alpha), ActionController::LogSubscriber, ActionView::LogSubscriber and ActiveRecord::LogSubscriber are no longer ActiveSupport::LogSubscribers attached to ActiveSupport::Notifications. They are ActiveSupport::EventReporter::LogSubscribers that receive structured events (action_controller.request_started, action_view.render_template, active_record.sql, ...) from Rails.event. The gem still looks for them in ActiveSupport::LogSubscriber.log_subscribers, so a Rails app on edge fails to boot with We could not find a log subscriber for :action_controller of type ActionController::LogSubscriber.

  • ActiveSupportLogSubscriber swaps such subscribers through Rails.event (unsubscribe the Rails one, subscribe ours) and keeps the notifications path for Rails ≤ 8.1. Like attach_to, it only delivers the events for the methods the Logtail subscriber defines itself, so Rails' own Completed 200 OK line stays replaced by the http_response_sent event as before.
  • The three LogtailLogSubscribers get a Rails 8.2 body next to the existing one: the same controller_called, template_rendered and sql_query_executed events with the same messages, read from the event payload hash (request_started instead of start_processing, duration_ms instead of event.duration).
  • EventLogSubscriber skips events in a namespace owned by a Rails log subscriber, because Rails 8.2 routes the framework's own instrumentation through Rails.event too. Application events keep being forwarded as before.
  • The spec app now loads the ActionController and ActionView railties: Rails 8.2 sets the template root the view subscribers strip in the action_view.root initializer, earlier versions derived it from Rails.root lazily.
  • The new EventLogSubscriber spec only runs where Rails.event exists. On Rails 5.0 and 5.1 mattr_accessor ignores default:, so the subscriber's enabled flag is nil there, which never mattered because nothing subscribes it before 8.1.
  • Rails main requires Ruby 3.3.1, so the rails-edge × Ruby 3.2 matrix entry is excluded.

Commits: the first only adds tests (an EventLogSubscriber spec and an 8.2-shaped fixture for the ActionView unit tests) and is expected to fail on the rails-edge jobs, where the suite cannot even load. The second loads the railties in the spec app and is still red on edge. The third makes the edge suite pass, the fourth and fifth are the spec guard and the matrix exclude above.

Red on main already and untouched here: the rails-7.x and rails-8.0 jobs on Ruby ≥ 3.2 (those Rails versions pass quirks_mode to JSON.generate, which json 3.0 dropped) and truffleruby × rails-edge (the gemspec's sqlite3 ~> 1.5.0 for that platform conflicts with the gemfile's >= 2.0).

🤖 Generated with Claude Code

PetrHeinz and others added 5 commits September 23, 2026 16:33
Rails main turned the framework log subscribers into
ActiveSupport::EventReporter::LogSubscriber subclasses fed by Rails.event.
Pin the EventLogSubscriber behaviour (forward app events, skip the events
Rails already logs) and give the ActionView unit tests an 8.2-shaped event.
On rails-edge the suite still fails to load until the integration is ported.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Rails 8.2 sets ActionView::LogSubscriber.rails_root in the ActionView
railtie's action_view.root initializer, earlier versions derived it from
Rails.root lazily. Without the railtie the edge subscribers strip "/"
instead of the app root from template paths. The ActionView railtie
needs the ActionController one.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
On Rails main the controller, view and record log subscribers are
ActiveSupport::EventReporter::LogSubscribers fed by Rails.event, so the
gem could not find them in ActiveSupport::LogSubscriber.log_subscribers
and raised at boot.

ActiveSupportLogSubscriber swaps such subscribers through the event
reporter, delivering only the events for the methods the Logtail
subscriber defines itself, like attach_to does. The Logtail subscribers
get a Rails 8.2 body reading the event payload hash and emitting the same
controller_called, template_rendered and sql_query_executed events.
EventLogSubscriber skips the framework namespaces so the events Rails
already logs are not forwarded a second time.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Nothing subscribes the EventLogSubscriber before Rails 8.1. On Rails 5.0
and 5.1 mattr_accessor ignores the default: option, so its enabled flag
is nil there and emit logs nothing.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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