Sha256: a1e48f7a1eee8026a6c2c4d68732b3c33d42d13478a97b4d74c755cb387a0d6b

Contents?: true

Size: 796 Bytes

Versions: 5

Compression:

Stored size: 796 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)
          Trace.record do |trace|
            job['trace'] = trace.to_h
            yield
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
request-tracer-0.7.0 lib/request_tracer/integration/sidekiq_handler.rb
request-tracer-0.6.6 lib/request_tracer/integration/sidekiq_handler.rb
request-tracer-0.6.5 lib/request_tracer/integration/sidekiq_handler.rb
request-tracer-0.6.4 lib/request_tracer/integration/sidekiq_handler.rb
request-tracer-0.6.3 lib/request_tracer/integration/sidekiq_handler.rb