Class: Yabeda::Faktory::WorkerMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/yabeda/faktory/worker_middleware.rb

Overview

Faktory worker middleware

Instance Method Summary collapse

Instance Method Details

#call(_job_instance, payload) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/yabeda/faktory/worker_middleware.rb', line 7

def call(_job_instance, payload)
  success = true
  start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  yield
rescue Exception # rubocop: disable Lint/RescueException
  success = false
  raise
ensure
  elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
  labels = { success: success }.merge(Yabeda::Faktory.labelize(payload))
  Yabeda.faktory.job_execution_runtime.measure(labels, elapsed.round(3))
  Yabeda.faktory.jobs_executed_total.increment(labels)
end