Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Rails main (8.2.0.alpha),
ActionController::LogSubscriber,ActionView::LogSubscriberandActiveRecord::LogSubscriberare no longerActiveSupport::LogSubscribers attached toActiveSupport::Notifications. They areActiveSupport::EventReporter::LogSubscribers that receive structured events (action_controller.request_started,action_view.render_template,active_record.sql, ...) fromRails.event. The gem still looks for them inActiveSupport::LogSubscriber.log_subscribers, so a Rails app on edge fails to boot withWe could not find a log subscriber for :action_controller of type ActionController::LogSubscriber.ActiveSupportLogSubscriberswaps such subscribers throughRails.event(unsubscribethe Rails one,subscribeours) and keeps the notifications path for Rails ≤ 8.1. Likeattach_to, it only delivers the events for the methods the Logtail subscriber defines itself, so Rails' ownCompleted 200 OKline stays replaced by thehttp_response_sentevent as before.LogtailLogSubscribers get a Rails 8.2 body next to the existing one: the samecontroller_called,template_renderedandsql_query_executedevents with the same messages, read from the event payload hash (request_startedinstead ofstart_processing,duration_msinstead ofevent.duration).EventLogSubscriberskips events in a namespace owned by a Rails log subscriber, because Rails 8.2 routes the framework's own instrumentation throughRails.eventtoo. Application events keep being forwarded as before.action_view.rootinitializer, earlier versions derived it fromRails.rootlazily.EventLogSubscriberspec only runs whereRails.eventexists. On Rails 5.0 and 5.1mattr_accessorignoresdefault:, so the subscriber'senabledflag is nil there, which never mattered because nothing subscribes it before 8.1.rails-edge× Ruby 3.2 matrix entry is excluded.Commits: the first only adds tests (an
EventLogSubscriberspec and an 8.2-shaped fixture for the ActionView unit tests) and is expected to fail on therails-edgejobs, 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
mainalready and untouched here: therails-7.xandrails-8.0jobs on Ruby ≥ 3.2 (those Rails versions passquirks_modetoJSON.generate, which json 3.0 dropped) andtruffleruby×rails-edge(the gemspec'ssqlite3 ~> 1.5.0for that platform conflicts with the gemfile's>= 2.0).🤖 Generated with Claude Code