Sha256: aff5fa8d26564418c0ba8338b2ab3f3ae7626f69ab6ed58efd242dc9c754c35d

Contents?: true

Size: 654 Bytes

Versions: 3

Compression:

Stored size: 654 Bytes

Contents

# frozen_string_literal: true

require "opentracing"

module Labkit
  module Tracing
    module Sidekiq
      # ServerMiddleware provides a sidekiq server middleware for
      # instrumenting distributed tracing calls when they are
      # executed by the Sidekiq server
      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)) { |_span| yield }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gitlab-labkit-0.1.2 lib/labkit/tracing/sidekiq/server_middleware.rb
gitlab-labkit-0.1.0.pre.1.pre.gcb57c95 lib/labkit/tracing/sidekiq/server_middleware.rb
gitlab-labkit-0.1.0 lib/labkit/tracing/sidekiq/server_middleware.rb