Allow backtrace cleaner to be configured#453
Conversation
f4f5efc to
fdb5fdd
Compare
gmcgibbon
left a comment
There was a problem hiding this comment.
You'll want to set the value in rails config and then add defaults in an initializer block. See https://github.com/Shopify/app_profiler/blob/78cb8b579a2bbf3034c6941f9adb865f5ef3d283/lib/app_profiler/railtie.rb#L10 (for example).
fdb5fdd to
59eb202
Compare
|
Thanks @gmcgibbon, I was hoping there was a better way to do that! ❤️ |
| end | ||
|
|
||
| initializer "maintenance_tasks.configs" do | ||
| MaintenanceTasks.backtrace_cleaner = Rails.backtrace_cleaner |
There was a problem hiding this comment.
| MaintenanceTasks.backtrace_cleaner = Rails.backtrace_cleaner | |
| MaintenanceTasks.backtrace_cleaner ||= Rails.backtrace_cleaner |
You could move configuration to a rails config option (eg. Rails.application.config.maintenance_tasks.*) in the engine, but this should work fine. Given there's already config options that don't follow this pattern, I think it is fine as-is.
There was a problem hiding this comment.
IIRC we went with this approach because the Rails engine docs identified using mattr_accessors as a valid pattern for setting config options on engines, but I do think that using Rails config options would be more appropriate. Maybe this is something we can revisit -- although the process to deprecate this and move people towards using config options is maybe more hassle than it's worth.
Rather than defaulting to
Rails.backtrace_cleanerfor cleaning the backtrace before persisting it inRun#persist_error, it would be nice if this could be configured. In Shopify/shopify, I need to add some silencers to remove lines related to our job infra / instrumentation from the backtrace, so I'd like to specify a new backtrace cleaner to be used by the gem for cleaning up Task backtraces.I think it makes sense to expose this as a config option -- users might have job-related lines that they want to include in traces as part of their default
Rails.backtrace_cleaner, but want to exclude from traces the gem shows.