Skip to content

Conversation

@Austio
Copy link

@Austio Austio commented Nov 25, 2025

Issue

See: rails/rails@7d12071

Closes #276
Closes #279

I cherry picked from zzak here and added specs showing the change passes to reduce burden on maintainer here.

I further addressed #276 (comment) by not writing to stats on rails 8.1 and later.

Description of changes

  • Adds 8.1 appraisal support
  • Patches runtime reader/writer to switch on stats being a method on ActiveRecord::RuntimeRegistry

Failing Spec with Adding Rails 8.1 support

Passing Spec with CherryPicking change from zzak

@jdelStrother
Copy link
Contributor

@Austio What do you make of grncdr's analysis here - #276 (comment) ?

IMO he's correct - this log subscriber shouldn't be messing with ActiveRecord's runtime stats. Just deleting the calls would break Rails 5/6 compatibility though, so it might need a version bump.

@Austio
Copy link
Author

Austio commented Dec 1, 2025

@jdelStrother Thank you - that is an excellent point i'll double check here and push a better change if it is valid (seems like it)

@Austio Austio force-pushed the add-rails-8.1-test branch from 4759fc6 to 8f85e1e Compare December 1, 2025 17:30
@Austio Austio changed the title Add rails 8.1 test Add rails 8.1 Support and Tests Dec 1, 2025
@Austio
Copy link
Author

Austio commented Dec 1, 2025

@jdelStrother Fixed for this change, if we want to backport this to other versions it would be a simple change of the constant to the versions we want to skip setting runtime on 8f85e1e

@Austio
Copy link
Author

Austio commented Dec 1, 2025

@reidmorrison Have this ready for review, should close the gap on the following

  • Rails 8.1 support and tests
  • Keeping older support

module ActiveRecord
class LogSubscriber < ActiveSupport::LogSubscriber
IGNORE_PAYLOAD_NAMES = %w[SCHEMA EXPLAIN].freeze
RAILS_VERSION_ENDING_SET_RUNTIME_SUPPORT = Gem::Version.new( "8.1")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on @Austio!

I think this should probably be set to 8.0 or 8.0.3

The original issue that tipped me off to this problem is #273 where the reporter says they are using 8.0.3, but I suspect that metrics have been double counted on even older versions, and @jeromepl is the first to notice.

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.

Change in Rails v8.1 breaks rails_semantic_logger/active_record/log_subscriber.rb

4 participants