Class: Sidekiq::Instrument::WorkerMetrics
- Inherits:
-
Object
- Object
- Sidekiq::Instrument::WorkerMetrics
- Defined in:
- lib/sidekiq/instrument/worker_metrics.rb
Overview
Stores worker count with a key sidekiq_instrument_trace_workers:#namespace:in_queue Values are hash having keys as worker names.
Class Method Summary collapse
- .reset_counter(key) ⇒ Object
- .reset_counters ⇒ Object
- .trace_workers_decrement_counter(klass_name) ⇒ Object
- .trace_workers_increment_counter(klass_name) ⇒ Object
- .worker_metric_name ⇒ Object
- .workers_in_queue ⇒ Object
Class Method Details
.reset_counter(key) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/sidekiq/instrument/worker_metrics.rb', line 38 def reset_counter(key) return unless enabled? Sidekiq.redis do |redis| redis.hdel(worker_metric_name, key) end end |
.reset_counters ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/sidekiq/instrument/worker_metrics.rb', line 29 def reset_counters return unless enabled? Sidekiq.redis do |redis| all_keys = redis.hgetall(worker_metric_name) redis.hdel(worker_metric_name, all_keys.keys) end end |
.trace_workers_decrement_counter(klass_name) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/sidekiq/instrument/worker_metrics.rb', line 21 def trace_workers_decrement_counter(klass_name) return unless enabled? Sidekiq.redis do |redis| redis.hincrby(worker_metric_name, klass_name, -1) end end |
.trace_workers_increment_counter(klass_name) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/sidekiq/instrument/worker_metrics.rb', line 13 def trace_workers_increment_counter(klass_name) return unless enabled? Sidekiq.redis do |redis| redis.hincrby(worker_metric_name, klass_name, 1) end end |
.worker_metric_name ⇒ Object
53 54 55 |
# File 'lib/sidekiq/instrument/worker_metrics.rb', line 53 def worker_metric_name "sidekiq_instrument_trace_workers:#{namespace}:in_queue" end |
.workers_in_queue ⇒ Object
46 47 48 49 50 51 |
# File 'lib/sidekiq/instrument/worker_metrics.rb', line 46 def workers_in_queue return unless enabled? Sidekiq.redis do |redis| redis.hgetall(worker_metric_name) end end |