Sha256: cae7d71853344264a6a54b021872e4b8fff1370c177d431aee2152484b3b8072

Contents?: true

Size: 1.42 KB

Versions: 12

Compression:

Stored size: 1.42 KB

Contents

require 'delayed_job'

module Delayed
  module Plugins

    class Raven < ::Delayed::Plugin
      callbacks do |lifecycle|
        lifecycle.around(:invoke_job) do |job, *args, &block|
          begin
            # Forward the call to the next callback in the callback chain
            block.call(job, *args)

          rescue Exception => exception
            # Log error to Sentry
            ::Raven.capture_exception(exception,
              :logger  => 'delayed_job',
              :tags    => {
                 :delayed_job_queue => job.queue
              },
              :extra => {
                  :delayed_job => {
                      :id          => job.id,
                      :priority    => job.priority,
                      :attempts    => job.attempts,
                      :handler     => job.handler,
                      :last_error  => job.last_error,
                      :run_at      => job.run_at,
                      :locked_at   => job.locked_at,
                      #failed_at  => job.failed_at,
                      :locked_by   => job.locked_by,
                      :queue       => job.queue,
                      :created_at  => job.created_at
                  }
              })

            # Make sure we propagate the failure!
            raise exception
          end
        end
      end
    end

  end
end

##
# Register DelayedJob Raven plugin
#
Delayed::Worker.plugins << Delayed::Plugins::Raven

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
sentry-raven-0.13.1 lib/raven/integrations/delayed_job.rb
sentry-raven-0.13.0 lib/raven/integrations/delayed_job.rb
sentry-raven-0.12.3 lib/raven/integrations/delayed_job.rb
sentry-raven-0.12.2 lib/raven/integrations/delayed_job.rb
sentry-raven-0.12.1 lib/raven/integrations/delayed_job.rb
sentry-raven-0.12.0 lib/raven/integrations/delayed_job.rb
mustwin-sentry-raven-0.11.2 lib/raven/integrations/delayed_job.rb
sentry-raven-0.11.2 lib/raven/integrations/delayed_job.rb
sentry-raven-0.11.1 lib/raven/integrations/delayed_job.rb
sentry-raven-0.10.1 lib/raven/integrations/delayed_job.rb
sentry-raven-0.9.4 lib/raven/integrations/delayed_job.rb
sentry-raven-0.9.3 lib/raven/integrations/delayed_job.rb