Class: ZipkinTracer::Sidekiq::Middleware
- Inherits:
-
Object
- Object
- ZipkinTracer::Sidekiq::Middleware
- Defined in:
- lib/zipkin-tracer/sidekiq/middleware.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#traceable_workers ⇒ Object
readonly
Returns the value of attribute traceable_workers.
-
#tracer ⇒ Object
readonly
Returns the value of attribute tracer.
Instance Method Summary collapse
- #call(worker, job, queue, &block) ⇒ Object
-
#initialize(config) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(config) ⇒ Middleware
Returns a new instance of Middleware.
6 7 8 9 10 |
# File 'lib/zipkin-tracer/sidekiq/middleware.rb', line 6 def initialize(config) @config = Config.new(nil, config).freeze @tracer = TracerFactory.new.tracer(@config) @traceable_workers = config.fetch(:traceable_workers, []) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/zipkin-tracer/sidekiq/middleware.rb', line 4 def config @config end |
#traceable_workers ⇒ Object (readonly)
Returns the value of attribute traceable_workers.
4 5 6 |
# File 'lib/zipkin-tracer/sidekiq/middleware.rb', line 4 def traceable_workers @traceable_workers end |
#tracer ⇒ Object (readonly)
Returns the value of attribute tracer.
4 5 6 |
# File 'lib/zipkin-tracer/sidekiq/middleware.rb', line 4 def tracer @tracer end |
Instance Method Details
#call(worker, job, queue, &block) ⇒ Object
12 13 14 15 16 |
# File 'lib/zipkin-tracer/sidekiq/middleware.rb', line 12 def call(worker, job, queue, &block) return block.call unless traceable_worker?(worker) trace(worker, job, queue, &block) end |