bugsnag / bugsnag-ruby

BugSnag error monitoring & reporting software for rails, sinatra, rack and ruby
https://docs.bugsnag.com/platforms/ruby
MIT License
249 stars 174 forks source link

Allow access to Bugnsag Sidekiq exception report before notifying Bugsnag #792

Closed cagmz closed 1 year ago

cagmz commented 1 year ago

Description

The Bugsnag Ruby gem integrates with Sidekiq and sends all worker parameters to Bugsnag when a notification is made. The user/dev cannot access the payload before it's made. This happens here: https://github.com/bugsnag/bugsnag-ruby/blob/bdfbf3972f2137b3b9b95194a6bedf9c8edf6555/lib/bugsnag/integrations/sidekiq.rb#L23

Describe the solution you'd like I'd like access to the Bugsnag notification report before it's sent to Bugsnag. This is because some job parameters may be sensitive, and I'd like to filter/censor the values before notifying Bugsnag.

Describe alternatives you've considered I manually removed the Bugsnag Sidekiq middleware and replaced it with my own which does mostly the same thing, except I'm able to filter/censor the report before it's made to Bugsnag.

# initializers/sidekiq.rb
Sidekiq.configure_server do |config|
  config.server_middleware do |chain|
    chain.remove(::Bugsnag::Sidekiq)
    chain.add(::Bugsnag::SidekiqFilteredReport)
  end
end

Additional context

imjoehaines commented 1 year ago

Hey @cagmz

You can redact parts of the metadata before its sent to Bugsnag by using the redacted_keys configuration option

If you need more control than this, you can use an on error callback to mutate the event object. This includes all of the Sidekiq metadata, which you could remove using event.clear_metadata

Hope that helps!