From 7619be8b86c658170cf870d3a4e812e25a5fec54 Mon Sep 17 00:00:00 2001 From: Austin Story Date: Tue, 25 Nov 2025 10:36:51 -0800 Subject: [PATCH 1/2] Add rails 8.1 specs --- .github/workflows/ci.yml | 3 +++ Appraisals | 5 +++++ gemfiles/rails_8.1.gemfile | 18 ++++++++++++++++++ test/active_record_test.rb | 8 ++++++++ 4 files changed, 34 insertions(+) create mode 100644 gemfiles/rails_8.1.gemfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e15429..3ca4268 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,9 @@ jobs: - rails: "8.0" ruby: "3.4" + - rails: "8.1" + ruby: "3.4" + env: BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.rails }}.gemfile DISPLAY: ":99.0" diff --git a/Appraisals b/Appraisals index fd8abe3..d119d50 100644 --- a/Appraisals +++ b/Appraisals @@ -43,3 +43,8 @@ appraise "rails_8.0" do gem "rails", "~> 8.0.0" gem "sidekiq", "~> 7.2.4" end + +appraise "rails_8.1" do + gem "rails", "~> 8.1.1" + gem "sidekiq", "~> 7.2.4" +end diff --git a/gemfiles/rails_8.1.gemfile b/gemfiles/rails_8.1.gemfile new file mode 100644 index 0000000..a907699 --- /dev/null +++ b/gemfiles/rails_8.1.gemfile @@ -0,0 +1,18 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "appraisal" +gem "puma" +gem "active_model_serializers" +gem "amazing_print" +gem "minitest" +gem "minitest-rails" +gem "rake" +gem "sprockets", "< 4.0" +gem "rails", "~> 8.1.1" +gem "sidekiq", "~> 7.2.4" +gem "sqlite3" +gem "rubocop" + +gemspec path: "../" diff --git a/test/active_record_test.rb b/test/active_record_test.rb index c3f194d..e78720c 100644 --- a/test/active_record_test.rb +++ b/test/active_record_test.rb @@ -225,5 +225,13 @@ class ActiveRecordTest < Minitest::Test assert_equal true, messages[1].payload[:async] end end + + describe "runtime" do + it "reads and writes the runtime" do + RailsSemanticLogger::ActiveRecord::LogSubscriber.runtime = 5.0 + + assert RailsSemanticLogger::ActiveRecord::LogSubscriber.runtime, 5.0 + end + end end end From af57798bd706f25e9dc7e73f19b6e24e224ec91d Mon Sep 17 00:00:00 2001 From: zzak Date: Thu, 16 Oct 2025 21:59:09 +0900 Subject: [PATCH 2/2] ActiveRecord::RuntimeRegistry.sql_runtime private API moved See: rails/rails@7d12071 --- lib/rails_semantic_logger/active_record/log_subscriber.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/rails_semantic_logger/active_record/log_subscriber.rb b/lib/rails_semantic_logger/active_record/log_subscriber.rb index 2e9fc73..5d2388c 100644 --- a/lib/rails_semantic_logger/active_record/log_subscriber.rb +++ b/lib/rails_semantic_logger/active_record/log_subscriber.rb @@ -8,11 +8,15 @@ class << self end def self.runtime=(value) - ::ActiveRecord::RuntimeRegistry.sql_runtime = value + ::ActiveRecord::RuntimeRegistry.respond_to?(:stats) ? + ::ActiveRecord::RuntimeRegistry.stats.sql_runtime = value : + ::ActiveRecord::RuntimeRegistry.sql_runtime = value end def self.runtime - ::ActiveRecord::RuntimeRegistry.sql_runtime ||= 0 + ::ActiveRecord::RuntimeRegistry.respond_to?(:stats) ? + ::ActiveRecord::RuntimeRegistry.stats.sql_runtime ||= 0 : + ::ActiveRecord::RuntimeRegistry.sql_runtime ||= 0 end def self.reset_runtime