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.
6 7 8 |
# File 'lib/prometheus_exporter/instrumentation/sidekiq.rb', line 6 def initialize(client: nil) @client = client || PrometheusExporter::Client.default end |
Instance Method Details
#call(worker, msg, queue) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/prometheus_exporter/instrumentation/sidekiq.rb', line 10 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 class_name = if worker.class.to_s == 'ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper' msg['wrapped'] else worker.class.to_s end @client.send_json( type: "sidekiq", name: class_name, success: success, duration: duration ) end |