Class: PrometheusExporter::Instrumentation::Shoryuken
- Inherits:
-
Object
- Object
- PrometheusExporter::Instrumentation::Shoryuken
- Defined in:
- lib/prometheus_exporter/instrumentation/shoryuken.rb
Instance Method Summary collapse
- #call(worker, queue, msg, body) ⇒ Object
-
#initialize(client: nil) ⇒ Shoryuken
constructor
A new instance of Shoryuken.
Constructor Details
#initialize(client: nil) ⇒ Shoryuken
Returns a new instance of Shoryuken.
5 6 7 |
# File 'lib/prometheus_exporter/instrumentation/shoryuken.rb', line 5 def initialize(client: nil) @client = client || PrometheusExporter::Client.default end |
Instance Method Details
#call(worker, queue, msg, body) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/prometheus_exporter/instrumentation/shoryuken.rb', line 9 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 |