ca464b6033
This change allows the GitLab rails and sidekiq components to receive tracing spans from upstream services such as Workhorse and pass these spans on to downstream services including Gitaly and Sidekiq. This change will also emit traces for incoming and outgoing requests using the propagated trace information. This will allow operators and engineers to view traces across the Workhorse, GitLab Rails, Sidekiq and Gitaly components. Additional intra-service instrumentation will be added in future changes.
26 lines
546 B
Ruby
26 lines
546 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'opentracing'
|
|
|
|
module Gitlab
|
|
module Tracing
|
|
module Sidekiq
|
|
class ServerMiddleware
|
|
include SidekiqCommon
|
|
|
|
SPAN_KIND = 'server'
|
|
|
|
def call(worker, job, queue)
|
|
context = tracer.extract(OpenTracing::FORMAT_TEXT_MAP, job)
|
|
|
|
in_tracing_span(
|
|
operation_name: "sidekiq:#{job['class']}",
|
|
child_of: context,
|
|
tags: tags_from_job(job, SPAN_KIND)) do |span|
|
|
yield
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|