From a0e103e69744834a1142502b0f901cc1c4a52470 Mon Sep 17 00:00:00 2001 From: Roman Samoilov <2270393+rsamoilov@users.noreply.github.com> Date: Tue, 10 Feb 2026 13:45:37 +0000 Subject: [PATCH 1/2] Ensure configuration is built correctly inside `after_initialize` hooks --- lib/rage/configuration.rb | 1 + .../app/telemetry/test_controller_observer.rb | 9 +++++++ .../app/telemetry/test_exception_recorder.rb | 8 ++++++ .../test_app/config/application.rb | 25 +++---------------- 4 files changed, 22 insertions(+), 21 deletions(-) create mode 100644 spec/integration/test_app/app/telemetry/test_controller_observer.rb create mode 100644 spec/integration/test_app/app/telemetry/test_exception_recorder.rb diff --git a/lib/rage/configuration.rb b/lib/rage/configuration.rb index 92c6fa9c..f275fe64 100644 --- a/lib/rage/configuration.rb +++ b/lib/rage/configuration.rb @@ -227,6 +227,7 @@ def internal # @private def run_after_initialize! run_hooks_for!(:after_initialize, self) + __finalize end class LogContext diff --git a/spec/integration/test_app/app/telemetry/test_controller_observer.rb b/spec/integration/test_app/app/telemetry/test_controller_observer.rb new file mode 100644 index 00000000..8698d0ca --- /dev/null +++ b/spec/integration/test_app/app/telemetry/test_controller_observer.rb @@ -0,0 +1,9 @@ +class TestControllerObserver < Rage::Telemetry::Handler + handle "controller.action.process", with: :monitor_controllers + + def self.monitor_controllers(name:) + Rage.logger.tagged(name) do + yield + end + end +end diff --git a/spec/integration/test_app/app/telemetry/test_exception_recorder.rb b/spec/integration/test_app/app/telemetry/test_exception_recorder.rb new file mode 100644 index 00000000..8c36d03a --- /dev/null +++ b/spec/integration/test_app/app/telemetry/test_exception_recorder.rb @@ -0,0 +1,8 @@ +class TestExceptionRecorder < Rage::Telemetry::Handler + handle "controller.action.process", with: :record_exceptions + + def self.record_exceptions + result = yield + Rage.logger.error("telemetry recorded exception #{result.exception.message}") if result.error? + end +end diff --git a/spec/integration/test_app/config/application.rb b/spec/integration/test_app/config/application.rb index e9f23208..f9f95a02 100644 --- a/spec/integration/test_app/config/application.rb +++ b/spec/integration/test_app/config/application.rb @@ -18,25 +18,6 @@ def call(env) end end -class TestControllerObserver < Rage::Telemetry::Handler - handle "controller.action.process", with: :monitor_controllers - - def self.monitor_controllers(name:) - Rage.logger.tagged(name) do - yield - end - end -end - -class TestExceptionRecorder < Rage::Telemetry::Handler - handle "controller.action.process", with: :record_exceptions - - def self.record_exceptions - result = yield - Rage.logger.error("telemetry recorded exception #{result.exception.message}") if result.error? - end -end - Rage.configure do config.middleware.use TestMiddleware config.public_file_server.enabled = !!ENV["ENABLE_FILE_SERVER"] @@ -66,8 +47,10 @@ def self.record_exceptions end if ENV["ENABLE_TELEMETRY"] - config.telemetry.use TestControllerObserver - config.telemetry.use TestExceptionRecorder + config.after_initialize do + config.telemetry.use TestControllerObserver + config.telemetry.use TestExceptionRecorder + end end config.after_initialize do From 21d99634b6f51618f8fd4f004c40bb3bc447a425 Mon Sep 17 00:00:00 2001 From: Roman Samoilov <2270393+rsamoilov@users.noreply.github.com> Date: Tue, 10 Feb 2026 13:49:59 +0000 Subject: [PATCH 2/2] Bump version --- CHANGELOG.md | 6 ++++++ lib/rage/version.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1f3a60e..cca11b16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## [Unreleased] +## [1.20.1] - 2026-02-10 + +### Fixed + +- Ensure configuration is built correctly inside the `after_initialize` hooks (#208). + ## [1.20.0] - 2026-01-20 ### Added diff --git a/lib/rage/version.rb b/lib/rage/version.rb index 7ee629cb..12dda0a6 100644 --- a/lib/rage/version.rb +++ b/lib/rage/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Rage - VERSION = "1.20.0" + VERSION = "1.20.1" end