-
-
Notifications
You must be signed in to change notification settings - Fork 512
/
Copy pathsend_event_job.rb
33 lines (30 loc) · 995 Bytes
/
send_event_job.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
if defined?(ActiveJob)
module Sentry
parent_job =
if defined?(::ApplicationJob) && ::ApplicationJob.ancestors.include?(::ActiveJob::Base)
::ApplicationJob
else
::ActiveJob::Base
end
class SendEventJob < parent_job
# the event argument is usually large and creates noise
self.log_arguments = false if respond_to?(:log_arguments=)
# this will prevent infinite loop when there's an issue deserializing SentryJob
if respond_to?(:discard_on)
discard_on ActiveJob::DeserializationError
else
# mimic what discard_on does for Rails 5.0
rescue_from ActiveJob::DeserializationError do |exception|
logger.error "Discarded #{self.class} due to a #{exception}. The original exception was #{exception.cause.inspect}."
end
end
def perform(event, hint = {})
Sentry.send_event(event, hint)
end
end
end
else
module Sentry
class SendEventJob; end
end
end