Class: PrometheusExporter::Instrumentation::Sidekiq
- Inherits:
-
Object
- Object
- PrometheusExporter::Instrumentation::Sidekiq
- Defined in:
- lib/prometheus_exporter/instrumentation/sidekiq.rb
Instance Method Summary collapse
- #call(worker, msg, queue) ⇒ Object
-
#initialize(client: nil) ⇒ Sidekiq
constructor
A new instance of Sidekiq.
Constructor Details
#initialize(client: nil) ⇒ Sidekiq
Returns a new instance of Sidekiq.
4 5 6 |
# File 'lib/prometheus_exporter/instrumentation/sidekiq.rb', line 4 def initialize(client: nil) @client = client || PrometheusExporter::Client.default end |
Instance Method Details
#call(worker, msg, queue) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/prometheus_exporter/instrumentation/sidekiq.rb', line 8 def call(worker, msg, queue) success = false start = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) result = yield success = true result ensure duration = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - start @client.send_json( type: "sidekiq", name: worker.class.to_s, success: success, duration: duration ) end |