Sha256: bc4133a1af96d8c53e49636f5ca3dc23e16d539009e5b4274eb6e979bec73f74

Contents?: true

Size: 1.45 KB

Versions: 39

Compression:

Stored size: 1.45 KB

Contents

module Instana
  module Instrumentation
    class SidekiqClient
      def call(worker_class, msg, queue, _redis_pool)
        kv_payload = { :'sidekiq-client' => {} }
        kv_payload[:'sidekiq-client'][:queue] = queue
        kv_payload[:'sidekiq-client'][:job] = worker_class
        kv_payload[:'sidekiq-client'][:retry] = msg['retry'].to_s
        ::Instana.tracer.log_entry(:'sidekiq-client', kv_payload)

        # Temporary until we move connection collection to redis
        # instrumentation
        Sidekiq.redis_pool.with do |client|
          opts = client.respond_to?(:connection) ? client.connection : client.client.options
          kv_payload[:'sidekiq-client'][:'redis-url'] = "#{opts[:host]}:#{opts[:port]}"
        end

        context = ::Instana.tracer.context
        if context
          msg['X-Instana-T'] = context.trace_id_header
          msg['X-Instana-S'] = context.span_id_header
        end

        result = yield

        kv_payload[:'sidekiq-client'][:job_id] = result['jid']
        result
      rescue => e
        ::Instana.tracer.log_error(e)
        raise
      ensure
        ::Instana.tracer.log_exit(:'sidekiq-client', kv_payload)
      end
    end
  end
end

if defined?(::Sidekiq) && ::Instana.config[:'sidekiq-client'][:enabled]
  ::Sidekiq.configure_client do |cfg|
    cfg.client_middleware do |chain|
      ::Instana.logger.debug "Instrumenting Sidekiq client"
      chain.add ::Instana::Instrumentation::SidekiqClient
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
instana-1.193.2 lib/instana/instrumentation/sidekiq-client.rb
instana-1.192.1 lib/instana/instrumentation/sidekiq-client.rb
instana-1.192.0 lib/instana/instrumentation/sidekiq-client.rb
instana-1.13.0 lib/instana/instrumentation/sidekiq-client.rb
instana-1.12.0 lib/instana/instrumentation/sidekiq-client.rb
instana-1.11.8-java lib/instana/instrumentation/sidekiq-client.rb
instana-1.11.8 lib/instana/instrumentation/sidekiq-client.rb
instana-1.11.7 lib/instana/instrumentation/sidekiq-client.rb
instana-1.11.6 lib/instana/instrumentation/sidekiq-client.rb
instana-1.11.6-java lib/instana/instrumentation/sidekiq-client.rb
instana-1.11.5 lib/instana/instrumentation/sidekiq-client.rb
instana-1.11.5-java lib/instana/instrumentation/sidekiq-client.rb
instana-1.11.4-java lib/instana/instrumentation/sidekiq-client.rb
instana-1.11.4 lib/instana/instrumentation/sidekiq-client.rb
instana-1.11.3-java lib/instana/instrumentation/sidekiq-client.rb
instana-1.11.3 lib/instana/instrumentation/sidekiq-client.rb
instana-1.11.2-java lib/instana/instrumentation/sidekiq-client.rb
instana-1.11.2 lib/instana/instrumentation/sidekiq-client.rb
instana-1.11.1-java lib/instana/instrumentation/sidekiq-client.rb
instana-1.11.1 lib/instana/instrumentation/sidekiq-client.rb