summaryrefslogtreecommitdiff
path: root/lib/gitlab/tracing/sidekiq/server_middleware.rb
blob: 3728ee882c7988f6811ea3a5676a0ac221c0c309 (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
# frozen_string_literal: true

require 'opentracing'

module Gitlab
  module Tracing
    module Sidekiq
      class ServerMiddleware
        include SidekiqCommon

        def call(worker, job, queue)
          context = tracer.extract(OpenTracing::FORMAT_TEXT_MAP, job)

          start_active_span(
            operation_name: job['class'],
            child_of: context,
            tags: tags_from_job(job, 'server')) do |span|
            yield
          end
        end
      end
    end
  end
end