Class: Loga::Sidekiq5::JobLogger

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/loga/sidekiq5/job_logger.rb

Overview

The approach of using a custom job logger in sidekiq was introduced in v5.0: github.com/mperham/sidekiq/pull/3235

Constant Summary collapse

EVENT_TYPE =
'sidekiq'.freeze

Instance Method Summary collapse

Methods included from Utilities

#duration_in_ms

Instance Method Details

#call(item, _queue) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/loga/sidekiq5/job_logger.rb', line 18

def call(item, _queue)
  reset_data
  yield
rescue Exception => ex # rubocop:disable Lint/RescueException
  data['exception'] = ex

  raise
ensure
  assign_data(item)
  send_message
end

#dataObject



14
15
16
# File 'lib/loga/sidekiq5/job_logger.rb', line 14

def data
  @data ||= {}
end

#started_atObject



10
11
12
# File 'lib/loga/sidekiq5/job_logger.rb', line 10

def started_at
  @started_at ||= Time.now
end