Class: Gitlab::SidekiqMiddleware::ExtraDoneLogMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/sidekiq_middleware/extra_done_log_metadata.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
# File 'lib/gitlab/sidekiq_middleware/extra_done_log_metadata.rb', line 6

def call(worker, job, queue)
  yield

  # We needed a way to pass state from a worker in to the
  # Gitlab::SidekiqLogging::StructuredLogger . Unfortunately the
  # StructuredLogger itself is not a middleware so cannot access the
  # worker object. We also tried to use SafeRequestStore but to pass the
  # data up but that doesn't work either because this is reset in
  # Gitlab::SidekiqMiddleware::RequestStoreMiddleware inside yield for
  # the StructuredLogger so it's cleared before we get to logging the
  # done statement. As such the only way to do this is to pass the data
  # up in the `job` object. Since `job` is just a Hash we can add this
  # extra metadata there.
  if worker.respond_to?(:logging_extras)
    job.merge!(worker.logging_extras)
  end
end