21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/sentry/resque.rb', line 21
def record(queue, worker, payload, &block)
Sentry.with_scope do |scope|
begin
contexts = generate_contexts(queue, worker, payload)
scope.set_contexts(**contexts)
scope.set_tags("resque.queue" => queue)
name = contexts.dig(:"Active-Job", :job_class) || contexts.dig(:"Resque", :job_class)
scope.set_transaction_name(name, source: :task)
transaction = Sentry.start_transaction(
name: scope.transaction_name,
source: scope.transaction_source,
op: "queue.resque",
origin: SPAN_ORIGIN
)
scope.set_span(transaction) if transaction
yield
finish_transaction(transaction, 200)
rescue Exception => exception
raise_if_retries_remain(payload["class"], exception)
::Sentry::Resque.capture_exception(exception, hint: { background: false })
finish_transaction(transaction, 500)
raise
end
end
end
|