lib/sentry/rails/active_job.rb in sentry-rails-4.1.7 vs lib/sentry/rails/active_job.rb in sentry-rails-4.2.0
- old
+ new
@@ -1,12 +1,8 @@
module Sentry
module Rails
module ActiveJobExtensions
- ALREADY_SUPPORTED_SENTRY_ADAPTERS = %w(
- ActiveJob::QueueAdapters::SidekiqAdapter
- ).freeze
-
def self.included(base)
base.class_eval do
around_perform do |job, block|
if Sentry.initialized?
if already_supported_by_specific_integration?(job)
@@ -27,31 +23,33 @@
block.call
rescue Exception => e # rubocop:disable Lint/RescueException
rescue_handler_result = rescue_with_handler(e)
return rescue_handler_result if rescue_handler_result
- Sentry::Rails.capture_exception(e, extra: sentry_context(job))
+ Sentry::Rails.capture_exception(
+ e,
+ extra: sentry_context(job),
+ tags: {
+ job_id: job.job_id,
+ provider_job_id: job.provider_job_id
+ }
+ )
raise e
end
def already_supported_by_specific_integration?(job)
- ALREADY_SUPPORTED_SENTRY_ADAPTERS.include?(job.class.queue_adapter.class.to_s)
+ Sentry.configuration.rails.skippable_job_adapters.include?(job.class.queue_adapter.class.to_s)
end
def sentry_context(job)
- ctx = {
- :active_job => job.class.name,
- :arguments => job.arguments,
- :scheduled_at => job.scheduled_at,
- :job_id => job.job_id,
- :locale => job.locale
+ {
+ active_job: job.class.name,
+ arguments: job.arguments,
+ scheduled_at: job.scheduled_at,
+ job_id: job.job_id,
+ provider_job_id: job.provider_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