class PrometheusExporter::Instrumentation::Shoryuken

Public Class Methods

new(client: nil) click to toggle source
# File lib/prometheus_exporter/instrumentation/shoryuken.rb, line 6
def initialize(client: nil)
  @client = client || PrometheusExporter::Client.default
end

Public Instance Methods

call(worker, queue, msg, body) { || ... } click to toggle source
# File lib/prometheus_exporter/instrumentation/shoryuken.rb, line 10
def call(worker, queue, msg, body)
  success = false
  start = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
  result = yield
  success = true
  result
rescue ::Shoryuken::Shutdown => e
  shutdown = true
  raise e
ensure
  duration = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - start
  @client.send_json(
      type: "shoryuken",
      queue: queue,
      name: worker.class.name,
      success: success,
      shutdown: shutdown,
      duration: duration
  )
end