Class: Yabeda::Faktory::ClientMiddleware
- Inherits:
-
Object
- Object
- Yabeda::Faktory::ClientMiddleware
- Defined in:
- lib/yabeda/faktory/client_middleware.rb
Overview
Client middleware to count number of enqueued jobs
Instance Method Summary collapse
Instance Method Details
#call(payload, _connection_pool) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/yabeda/faktory/client_middleware.rb', line 7 def call(payload, _connection_pool) 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.jobs_enqueued_total.increment(labels) Yabeda.faktory.job_enqueue_runtime.measure(labels, elapsed.round(3)) end |