Skip to content

Conversation

@jeffkreeftmeijer
Copy link
Member

@jeffkreeftmeijer jeffkreeftmeijer commented Nov 20, 2025

Rails 8.1 adds ActiveSupport::EventReporter, an interface for reporting structured events. To catch these, report them as info-level logs in the rails_events category through the newly added Appsignal::Integrations::ActiveSupportEventReporter.

@jeffkreeftmeijer jeffkreeftmeijer self-assigned this Nov 20, 2025
@jeffkreeftmeijer jeffkreeftmeijer added the feature A new feature for this component. label Nov 20, 2025
Rails 8.1 adds ActiveSupport::EventReporter, an interface for
reporting structured events. To catch these, report them as info-level
logs in the rails_events category through the newly added
Appsignal::Integrations::ActiveSupportEventReporter.
@jeffkreeftmeijer jeffkreeftmeijer marked this pull request as ready for review November 21, 2025 13:34
@tombruijn tombruijn linked an issue Nov 24, 2025 that may be closed by this pull request
type: add
---

Report events from Rails 8.1's ActiveSupport::EventReporter as logs
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Report events from Rails 8.1's ActiveSupport::EventReporter as logs
Report events from Rails 8.1's Structured Event Reporting (`ActiveSupport::EventReporter`) as logs.

Comment on lines +24 to +37
# Mock Rails.event
stub_const("MockEventReporter", Class.new do
attr_reader :subscribers

def initialize
@subscribers = []
end

def subscribe(subscriber)
@subscribers << subscriber
end
end)

mock_event_reporter = MockEventReporter.new
Copy link
Member

Choose a reason for hiding this comment

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

I recommend using an instance double for this, so that if the Rails API for this ever changes, our tests fail too, and it doesn't silently keep passing the test. Keeping us unaware anything is broken.
https://rspec.info/features/3-12/rspec-mocks/verifying-doubles/instance-doubles/

Suggested change
# Mock Rails.event
stub_const("MockEventReporter", Class.new do
attr_reader :subscribers
def initialize
@subscribers = []
end
def subscribe(subscriber)
@subscribers << subscriber
end
end)
mock_event_reporter = MockEventReporter.new
# Mock Rails.event
subscribers = []
mock_event_reporter = instance_double(
"ActiveSupport::EventReporter",
:subscribe => nil,
:subscribers => subscribers
)
allow(mock_event_reporter).to receive(:subscribe) do |subscriber|
subscribers << subscriber
end

describe Appsignal::Hooks::ActiveSupportEventReporterHook do
begin
require "active_support/event_reporter"
rescue LoadError
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
rescue LoadError
rescue LoadError # rubocop:disable Lint/SuppressedException

Ignore RuboCop violation.

@backlog-helper
Copy link


This is a message from the daily scheduled checks.

New issue guide | Backlog management | Rules | Feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A new feature for this component.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rails 8.1 Structured Event Reporting

3 participants