Class: Sidekiq::Instrumental::Middleware::Base
- Inherits:
-
Object
- Object
- Sidekiq::Instrumental::Middleware::Base
- Defined in:
- lib/sidekiq/instrumental/middleware/base.rb
Overview
Shared base code for measuring stats for server and client sidekiq
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #call(worker_instance, msg, queue, _redis_pool = nil) ⇒ Object
-
#initialize(config) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(config) ⇒ Base
Returns a new instance of Base.
12 13 14 |
# File 'lib/sidekiq/instrumental/middleware/base.rb', line 12 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/sidekiq/instrumental/middleware/base.rb', line 10 def config @config end |
Instance Method Details
#call(worker_instance, msg, queue, _redis_pool = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sidekiq/instrumental/middleware/base.rb', line 16 def call(worker_instance, msg, queue, _redis_pool = nil) start_time = Time.now result = yield elapsed = (Time.now - start_time).to_f return result unless config.enabled? track( ::Sidekiq::Stats.new, worker_instance, ::Sidekiq::Job.new(msg), queue, elapsed ) result end |