Skip to content

Enable debug mode for events in local environments - #55566

Merged
byroot merged 2 commits into
rails:mainfrom
Shopify:ac-enable-debug-events-in-local-envs
Aug 29, 2025
Merged

byroot merged 2 commits into
rails:mainfrom
Shopify:ac-enable-debug-events-in-local-envs

Conversation

@adrianna-chang-shopify

@adrianna-chang-shopify adrianna-chang-shopify commented Aug 28, 2025 •

Copy link
Copy Markdown
Contributor

Motivation / Background

Emit debug events by default in local environments. It would be good for devs to be able to see debug events when working locally, and it's also a bit of a pain to have to wrap tests in Rails.event.with_debug any time we want to assert that a debug event was emitted.

Detail

Sets a new option on the Event Reporter, debug_mode, which will force the event reporter into debug mode. When bootstrapping the app, we configure that value based on config.consider_all_requests_local.

Also two small cleanups -- removed an unused tags kwarg from the constructor, and ensured #notify returns nil.

Additional information

I considered combining debug_mode with raise_on_error, but decided it was clearer to keep them separate. We set both of them for local requests, but they don't mean the same thing. The former is enabling the emission of all debug events, and the latter defines behaviour if we encounter an error during event emission / in the subscriber code.

I've also opted to no'doc debug_mode, I don't think apps should set this directly.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.


self.context_store = EventContext

def initialize(*subscribers, raise_on_error: false, tags: nil)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

tags was unused

@byroot
byroot merged commit 6c3ab5d into rails:main Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants