Class: Skylight::Core::Sidekiq::ServerMiddleware

Inherits:
Object
  • Object
show all
Includes:
Util::Logging
Defined in:
lib/skylight/core/sidekiq.rb

Instance Method Summary collapse

Methods included from Util::Logging

#config_for_logging, #debug, #error, #fmt, #info, #log, #log_context, #log_env_prefix, #raise_on_error?, #t, #trace, #trace?, #warn

Constructor Details

#initialize(instrumentable) ⇒ ServerMiddleware

Returns a new instance of ServerMiddleware.


23
24
25
# File 'lib/skylight/core/sidekiq.rb', line 23

def initialize(instrumentable)
  @instrumentable = instrumentable
end

Instance Method Details

#call(_worker, job, queue) ⇒ Object


27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/skylight/core/sidekiq.rb', line 27

def call(_worker, job, queue)
  t { "Sidekiq middleware beginning trace" }
  title = job["wrapped"] || job["class"]
  @instrumentable.trace(title, "app.sidekiq.worker", title, segment: queue, component: :worker) do |trace|
    begin
      yield
    rescue Exception # includes Sidekiq::Shutdown
      trace.segment = "error" if trace
      raise
    end
  end
end