Module: Raven::Rails::ActiveJobExtensions
- Included in:
- ActiveJob::Base
- Defined in:
- lib/raven/integrations/rails/active_job.rb
Constant Summary collapse
- ALREADY_SUPPORTED_SENTRY_ADAPTERS =
%w( ActiveJob::QueueAdapters::SidekiqAdapter ActiveJob::QueueAdapters::DelayedJobAdapter ).freeze
Class Method Summary collapse
Instance Method Summary collapse
- #already_supported_by_specific_integration?(job) ⇒ Boolean
- #capture_and_reraise_with_sentry(job, block) ⇒ Object
- #raven_context(job) ⇒ Object
Class Method Details
.included(base) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/raven/integrations/rails/active_job.rb', line 9 def self.included(base) base.class_eval do around_perform do |job, block| capture_and_reraise_with_sentry(job, block) end end end |
Instance Method Details
#already_supported_by_specific_integration?(job) ⇒ Boolean
30 31 32 33 34 35 36 |
# File 'lib/raven/integrations/rails/active_job.rb', line 30 def already_supported_by_specific_integration?(job) if ::Rails.version.to_f < 5.0 ALREADY_SUPPORTED_SENTRY_ADAPTERS.include?(job.class.queue_adapter.to_s) else ALREADY_SUPPORTED_SENTRY_ADAPTERS.include?(job.class.queue_adapter.class.to_s) end end |
#capture_and_reraise_with_sentry(job, block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/raven/integrations/rails/active_job.rb', line 17 def capture_and_reraise_with_sentry(job, block) block.call rescue Exception => exception # rubocop:disable Lint/RescueException return if rescue_with_handler(exception) unless already_supported_by_specific_integration?(job) Raven.capture_exception(exception, :extra => raven_context(job)) end raise exception ensure Context.clear! BreadcrumbBuffer.clear! end |
#raven_context(job) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/raven/integrations/rails/active_job.rb', line 38 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 |