Class: Gitlab::SidekiqMiddleware::InstrumentationLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/sidekiq_middleware/instrumentation_logger.rb

Instance Method Summary collapse

Instance Method Details

#call(worker, job, queue) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gitlab/sidekiq_middleware/instrumentation_logger.rb', line 6

def call(worker, job, queue)
  ::Gitlab::InstrumentationHelper.init_instrumentation_data

  yield

ensure
  # The Sidekiq logger is called outside the middleware block, so
  # we need to modify the job hash to pass along this information
  # since RequestStore is only active in the Sidekiq middleware.
  #
  # Modifying the job hash in a middleware is permitted by Sidekiq
  # because Sidekiq keeps a pristine copy of the original hash
  # before sending it to the middleware:
  # https://github.com/mperham/sidekiq/blob/53bd529a0c3f901879925b8390353129c465b1f2/lib/sidekiq/processor.rb#L115-L118
  job[:instrumentation] = {}.tap do |instrumentation_values|
    ::Gitlab::InstrumentationHelper.add_instrumentation_data(instrumentation_values)
  end
end