Class: ZipkinTracer::Sidekiq::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/zipkin-tracer/sidekiq/middleware.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#configObject (readonly)

Returns the value of attribute config.



4
5
6
# File 'lib/zipkin-tracer/sidekiq/middleware.rb', line 4

def config
  @config
end

#traceable_workersObject (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

#tracerObject (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