Skip to content

Asynchronous configuration with Sidekiq #692

Description

@stve

What is the best way to configure asynchronous configuration with Sidekiq? I don't want to pass the full Raven::Event instance to the Sidekiq worker so I'm thinking of doing something like this:

config.async = lambda do |event|
  SentryWorker.perform_async(event_to_hash.to_json)
end

And then in my worker, I would convert the JSON back into a Raven::Event before calling Raven.send_event on it:

class SentryWorker
  include Sidekiq::Worker

  def perform(event_json)
    event = create_event_from_json(event_json)
    Raven.send_event(event)
  rescue JSON::ParseError
  end
end

I've looked through the Raven::Event source and there doesn't appear to be an obvious way to re-create the event from a hash. It'd be nice if there were Raven::Event.from_hash method, but in lieu of that should I create a new event in the worker and pass in the details from the hash. That approach seems possible with the exception of the interfaces portion of the object.

Am I missing something? Or am I on the right track?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions