Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ jobs:
matrix:
include:
- ruby: '3.3' # v1.x sqlite3 requires Ruby 3.3
rails: '7.0'
rails: '7.0.0'
bundler: 'default'
- ruby: '3.4'
rails: '7.1'
rails: '7.1.0'
bundler: 'default'
- ruby: '3.4'
rails: '7.2'
rails: '7.2.0'
bundler: 'default'
- ruby: '3.4'
rails: '8.0.0'
bundler: 'default'
- ruby: '3.4'
rails: '8.1.0'
bundler: 'default'
env:
RAILS_VERSION: ${{ matrix.rails }}
Expand All @@ -33,14 +39,14 @@ jobs:
bundler: ${{ matrix.bundler }}
bundler-cache: true
- run: bundle exec rubocop
if: matrix.rails == '7.1'
if: matrix.rails == '8.0.0'
- run: bundle exec rspec --format doc
- uses: codecov/codecov-action@v3
if: matrix.rails == '7.1'
if: matrix.rails == '8.0.0'
with:
files: coverage/coverage.xml
- run: bin/yardoc --fail-on-warning
if: matrix.rails == '7.1'
if: matrix.rails == '8.0.0'
- run: bin/check-version

release:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.10.0

- Add support for Rails 8.0 and Rails 8.1
- Fix ActiveRecord subscriber for Rails 8.1 RuntimeRegistry API change
- Fix CI version pinning to use three-segment version constraints

## 0.9.2

- Fix double log issue in Rails 7.1+
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source 'https://rubygems.org'
gemspec

not_jruby = %i[ruby mingw x64_mingw].freeze
rails_version = Gem::Version.new(ENV.fetch('RAILS_VERSION', '7.1.0'))
rails_version = Gem::Version.new(ENV.fetch('RAILS_VERSION', '8.0.0'))

gem 'byebug', platforms: not_jruby
gem 'rails', "~> #{rails_version}"
Expand Down
13 changes: 12 additions & 1 deletion lib/epilog/rails/active_record_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ActiveRecordSubscriber < LogSubscriber
IGNORE_PAYLOAD_NAMES = %w[SCHEMA EXPLAIN].freeze

def sql(event)
ActiveRecord::RuntimeRegistry.sql_runtime = (ActiveRecord::RuntimeRegistry.sql_runtime || 0) + event.duration
record_sql_runtime(event.duration)

return unless logger.debug?

Expand All @@ -23,6 +23,17 @@ def sql(event)

private

# Rails 8.1 moved sql_runtime from a module-level accessor to
# ActiveRecord::RuntimeRegistry.stats.sql_runtime (a Stats object).
# See https://github.com/rails/rails/commit/7d12071e9fe94bd5c01a488ef61718fe88de65b4
def record_sql_runtime(duration)
if ActiveRecord::RuntimeRegistry.respond_to?(:sql_runtime=)
ActiveRecord::RuntimeRegistry.sql_runtime = (ActiveRecord::RuntimeRegistry.sql_runtime || 0) + duration
else
ActiveRecord::RuntimeRegistry.stats.sql_runtime += duration
end
end

def metrics(event)
{
query_runtime: event.duration.round(2)
Expand Down
2 changes: 1 addition & 1 deletion lib/epilog/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Epilog
VERSION = '0.9.2'
VERSION = '0.10.0'

def self.version
Gem::Version.new(VERSION)
Expand Down
2 changes: 1 addition & 1 deletion spec/rails_app/app/controllers/redirect_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

class RedirectController < ActionController::Base
def index
redirect_to 'https://www.google.com'
redirect_to 'https://www.google.com', allow_other_host: true
end
end
Loading