Welcome to mirror list, hosted at ThFree Co, Russian Federation.

extra_done_log_metadata.rb « sidekiq_middleware « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 93c3131d50e547403e5f3b53a1d5c5f8ae6806e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

module Gitlab
  module SidekiqMiddleware
    class ExtraDoneLogMetadata
      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
    end
  end
end