Class: NSA::Collectors::Sidekiq
- Inherits:
-
Object
- Object
- NSA::Collectors::Sidekiq
- Includes:
- Statsd::Publisher
- Defined in:
- lib/nsa/collectors/sidekiq.rb
Instance Attribute Summary collapse
-
#key_prefix ⇒ Object
readonly
Returns the value of attribute key_prefix.
Class Method Summary collapse
Instance Method Summary collapse
- #call(worker, message, queue_name) ⇒ Object
-
#initialize(key_prefix) ⇒ Sidekiq
constructor
A new instance of Sidekiq.
Methods included from Statsd::Publisher
#__statsd_publish, #statsd_count, #statsd_decrement, #statsd_gauge, #statsd_increment, #statsd_set, #statsd_time, #statsd_timing
Constructor Details
#initialize(key_prefix) ⇒ Sidekiq
Returns a new instance of Sidekiq.
23 24 25 |
# File 'lib/nsa/collectors/sidekiq.rb', line 23 def initialize(key_prefix) self.key_prefix = key_prefix.to_s.split(".") end |
Instance Attribute Details
#key_prefix ⇒ Object
Returns the value of attribute key_prefix.
20 21 22 |
# File 'lib/nsa/collectors/sidekiq.rb', line 20 def key_prefix @key_prefix end |
Class Method Details
.collect(key_prefix) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/nsa/collectors/sidekiq.rb', line 8 def self.collect(key_prefix) require "sidekiq" ::Sidekiq.configure_server do |config| config.server_middleware do |chain| chain.add(::NSA::Collectors::Sidekiq, key_prefix) end end rescue ::LoadError => exception $stderr.puts("[LoadError] Failed to load sidekiq!", exception., *(exception.backtrace)) end |
Instance Method Details
#call(worker, message, queue_name) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nsa/collectors/sidekiq.rb', line 27 def call(worker, , queue_name) worker_name = worker.class.name.tr("::", ".") statsd_time(make_key(worker_name, :processing_time)) do yield end statsd_increment(make_key(worker_name, :success)) rescue => exception statsd_increment(make_key(worker_name, :failure)) fail exception ensure publish_overall_stats publish_queue_size_and_latency(queue_name) end |