Sha256: 9f37350aa01c09b0fa56aaf3b2a5d99b25b19f1efc5eeb5b5c2a7cc0c97cbc10

Contents?: true

Size: 741 Bytes

Versions: 3

Compression:

Stored size: 741 Bytes

Contents

# frozen_string_literal: true

require "opentracing"

module Labkit
  module Tracing
    module Sidekiq
      # ClientMiddleware provides a sidekiq client middleware for
      # instrumenting distributed tracing calls made from the client
      # application
      class ClientMiddleware
        include SidekiqCommon

        SPAN_KIND = "client"

        def call(_worker_class, job, _queue, _redis_pool)
          in_tracing_span(operation_name: "sidekiq:#{job["class"]}", tags: tags_from_job(job, SPAN_KIND)) do |span|
            # Inject the details directly into the job
            tracer
              .inject(span.context, OpenTracing::FORMAT_TEXT_MAP, job)

            yield
          end
        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/client_middleware.rb
gitlab-labkit-0.1.0.pre.1.pre.gcb57c95 lib/labkit/tracing/sidekiq/client_middleware.rb
gitlab-labkit-0.1.0 lib/labkit/tracing/sidekiq/client_middleware.rb