Sha256: 9b3ea2d1185975daad5affa66fce4ac435576e78c0ebfb56789817508dba9889
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
module Raven class Rails module ActiveJobExtensions ALREADY_SUPPORTED_SENTRY_ADAPTERS = %w( ActiveJob::QueueAdapters::SidekiqAdapter ActiveJob::QueueAdapters::DelayedJobAdapter ).freeze def self.included(base) base.class_eval do around_perform do |job, block| capture_and_reraise_with_sentry(job, block) end end end def capture_and_reraise_with_sentry(job, block) block.call rescue Exception => exception # rubocop:disable Lint/RescueException return if rescue_with_handler(exception) return if already_supported_by_specific_integration?(job) Raven.capture_exception(exception, :extra => raven_context(job)) raise exception ensure Context.clear! BreadcrumbBuffer.clear! end def already_supported_by_specific_integration?(job) ALREADY_SUPPORTED_SENTRY_ADAPTERS.include?(job.class.queue_adapter.to_s) end def raven_context(job) ctx = { :active_job => job.class.name, :arguments => job.arguments, :scheduled_at => job.scheduled_at, :job_id => job.job_id, :locale => job.locale } # Add provider_job_id details if Rails 5 if job.respond_to?(:provider_job_id) ctx[:provider_job_id] = job.provider_job_id end ctx end end end end class ActiveJob::Base include Raven::Rails::ActiveJobExtensions end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sentry-raven-2.6.1 | lib/raven/integrations/rails/active_job.rb |