warrenbhw
(Ben Warren)
December 8, 2022, 12:18am
1
rails:main
← warrenbhw:warrenbhw/active-job-backtrace-cleaner
opened 12:45AM - 23 Nov 22 UTC
### Motivation / Background
ActiveJob produces a large amount of log noise, b… ecause errors that are emitted from ActiveJob don't have the standard Rails BacktraceCleaner applied. This is especially apparent when using Sorbet for Ruby types, since each application method call is wrapped by multiple Sorbet typechecking functions. My application's activejob error backtraces would typically log 4 non-relevant Sorbet function calls for each application function call. My workaround has been to monkey-patch Rails in our application. However, it seems to make sense to simply bring this behavior into ActiveJob as the default, as the backtrace cleaner is a pretty standard piece of Rails machinery that is used for most other backtraces in Rails.
### Additional information
When ActiveJob encounters an error performing a job, rather than printing the full unfiltered (and noisy) exception backtrace, print the cleaned backtrace using Rails's BacktraceCleaner.
### Checklist
Before submitting the PR make sure the following are checked:
* [x] This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
* [x] 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]`
* [x] Tests are added or updated if you fix a bug or add a feature.
* [x] 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.
* [x] CI is passing.
ActiveJob produces a large amount of log noise, because errors that are emitted from ActiveJob don’t have the standard Rails BacktraceCleaner applied. This is especially apparent when using Sorbet for Ruby types.
The fix is just a few lines of code. Would be great if someone has time to review and merge my PR - just want to nudge this along, because I got some very quick initial feedback, but have been waiting on approval for a week or two.
Thanks!
1 Like