Class: NeetoMonitorRuby::Plugins::Sidekiq::ServerMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/neeto_monitor_ruby/plugins/sidekiq.rb

Constant Summary collapse

SKIPPED_WORKERS =
%w(ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sidekiq_workerObject (readonly)

Returns the value of attribute sidekiq_worker.



11
12
13
# File 'lib/neeto_monitor_ruby/plugins/sidekiq.rb', line 11

def sidekiq_worker
  @sidekiq_worker
end

Instance Method Details

#call(worker, _message, _queue) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/neeto_monitor_ruby/plugins/sidekiq.rb', line 13

def call(worker, _message, _queue)
  @sidekiq_worker = worker

  job_ping(state: MonitorUtils::JOB_STATES[:run])

  worker_result = yield

  job_ping(state: MonitorUtils::JOB_STATES[:complete])

  worker_result
rescue => exception
  job_ping(state: MonitorUtils::JOB_STATES[:fail], message: exception.message)

  raise exception
end