Class: Sciosano::Integrations::Sidekiq::ServerMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/sciosano/integrations/sidekiq.rb

Overview

Server middleware (runs on job worker)

Instance Method Summary collapse

Instance Method Details

#call(worker, job, queue) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sciosano/integrations/sidekiq.rb', line 9

def call(worker, job, queue)
  # Add job breadcrumb
  add_job_breadcrumb(worker, job, queue)

  # Set job context
  Sciosano.client&.with_context(
    extra: {
      sidekiq_job: job["class"],
      sidekiq_queue: queue,
      sidekiq_jid: job["jid"],
      sidekiq_retry_count: job["retry_count"]
    }
  ) do
    yield
  end
rescue Exception => e # rubocop:disable Lint/RescueException
  capture_exception(e, worker, job, queue)
  raise
end