Add :report behavior to ActiveSupport::Deprecation #48578
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This behavior uses the ErrorReporter to report a deprecation as a handled error with
:warning
severity.Motivation / Background
The error reporter is a great way to report on errors happening in production, with a way to declare the "error" as handled. In the lifecycle of an application, after upgrading to a new minor, deprecations can be slowly resolved and even marked as disallowed to prevent reintroduction, then deprecations can be configured to raise in development/test to make sure they don't reappear or are not ignored. But typically deprecations are completely silenced in production, with the
config.active_support.report_deprecations
configuration option.At the very last step before upgrading to the subsequent minor, if tests are not fully trusted to cover all code paths, it would be nice to be able to report deprecations happening in production to the bug tracker the application uses.
Detail
I debated whether to de-duplicate reports by somehow keeping track of backtraces or things like that. Ultimately I felt like this wasn't super useful since multiple worker processes will still report the same deprecation multiple times, and it would add complexity to the implementation.
By default, reported errors are marked as handled and have a severity of
:warning
. I wondered about using:info
to denote that it's very low cause for concern, but since the terminology is "deprecation warning" I went with what's the default for handled errors.Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]