Sha256: 4c57f7bc8abb209493f056e799d0c2199d3ec55701deedc1a98abbb14ec9f5c4

Contents?: true

Size: 751 Bytes

Versions: 1

Compression:

Stored size: 751 Bytes

Contents

require_relative 'base'
require_relative '../trace'
module RequestTracer
  module Integration
    module SidekiqHandler
      include Base
      extend self
      def activate
        require 'sidekiq'
        Sidekiq.server_middleware do |chain|
          chain.add ServerMiddleware
        end
        Sidekiq.client_middleware do |chain|
          chain.add ClientMiddleware
        end
      end

      class ServerMiddleware
        def call(worker, msg, queue)
          Trace.push(msg["trace"]) do |trace|
            yield
          end
        end
      end

      class ClientMiddleware
        def call(worker_class, job, queue, redis_pool)
          job['trace'] = Trace.latest.to_h
          yield
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
request-tracer-0.6.2 lib/request_tracer/integration/sidekiq_handler.rb