Class: Skylight::Sidekiq::ServerMiddleware

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

Instance Method Summary collapse

Methods included from Util::Logging

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

Instance Method Details

#call(worker, job, queue) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/skylight/sidekiq.rb', line 22

def call(worker, job, queue)
  t { "Sidekiq middleware beginning trace" }
  title = job["display_class"] || job["wrapped"] || job["class"]

  # TODO: Using hints here would be ideal but requires further refactoring
  meta =
    if (source_location = worker.method(:perform).source_location)
      { source_file: source_location[0], source_line: source_location[1] }
    end

  Skylight.trace(title, "app.sidekiq.worker", title, meta: meta, segment: queue, component: :worker) do |trace|
    yield
  rescue Exception # includes Sidekiq::Shutdown
    trace.segment = "error" if trace
    raise
  end
end