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
|
# File 'lib/rails_performance/gems/sidekiq_ext.rb', line 8
def call(worker, msg, queue)
now = Time.current
record = RailsPerformance::Models::SidekiqRecord.new(
enqueued_ati: msg['enqueued_at'].to_i,
datetimei: msg['created_at'].to_i,
jid: msg['jid'],
queue: queue,
start_timei: now.to_i,
datetime: now.strftime(RailsPerformance::FORMAT),
worker: msg['wrapped'.freeze] || worker.class.to_s
)
begin
result = yield
record.status = "success"
result
rescue Exception => ex
record.status = "exception"
record.message = ex.message
raise ex
ensure
record.duration = (Time.current - now) * 1000
record.save
result
end
end
|