Skip to content

Sidekiq error context/job params isn't added to manually reported errors #785

Description

@joshuap

We currently set the job params and component/action in our Sidekiq error handler:

opts = {parameters: params}
if config[:"sidekiq.use_component"]
opts[:component] = job["wrapped".freeze] || job["class".freeze]
opts[:action] = "perform" if opts[:component]
end
Honeybadger.notify(ex, **opts)

If someone rescues/handles an exception in a job and manually reports it to Honeybadger, that info isn't reported with the error:

class HardJob,
  include Sidekiq::Job

  def perform(name, count)
    rescue => error
      Honeybadger.notify(error) # Doesn't include job context
    end
  end
end

We may be able to solve this by using Honeybadger.context to add the job context in our Sidekiq middleware instead:

module Sidekiq
class Middleware
def call(_worker, _msg, _queue)
Honeybadger.clear!
yield
end
end

However, switching to Honeybadger.context would break compatibility since we currently send the job context in the notice's parameters, not context. We'd need a way to add the params like we do for context. The new ExecutionContext store I added to #771 might be useful for that, once it's merged.

References

Front logo Front conversations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions