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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/sidekiq-gelf/middleware.rb', line 9
def call(worker, item, queue)
Sidekiq::Logging.with_context("#{worker.class.to_s} JID-#{item['jid']}") do
begin
logger.info(filter_fields({
short_message: "Start: #{worker.class.to_s} JID-#{item['jid']}",
jid: item['jid'],
pid: pid,
tid: tid,
context: context,
worker: worker.class.to_s,
queue: queue,
params: item['args'],
latency: Sidekiq::Job.new(Sidekiq.dump_json(item)).latency,
memory: memory
}))
start = Time.now
yield
logger.info(filter_fields({
short_message: "Done: #{worker.class.to_s} JID-#{item['jid']}",
jid: item['jid'],
pid: pid,
tid: tid,
context: context,
worker: worker.class.to_s,
queue: queue,
params: item['args'],
runtime: elapsed(start),
memory: memory
}))
rescue Exception => e
logger.error(filter_fields({
short_message: "Fail: #{worker.class.to_s} JID-#{item['jid']}",
jid: item['jid'],
pid: pid,
tid: tid,
context: context,
worker: worker.class.to_s,
queue: queue,
params: item['args'],
runtime: elapsed(start),
exception_class: e.class.to_s,
exception_message: e.message,
backtrace: e.backtrace.join("\n"),
memory: memory
}))
raise e
end
end
end
|