Sha256: 14cb3bbfbad0cfa96a60889045bb9c869ced14438662460a38c7c296a00592fe

Contents?: true

Size: 1.36 KB

Versions: 7

Compression:

Stored size: 1.36 KB

Contents

require_relative '../patcher'
require_relative 'configuration/resolver'
require_relative 'ext'
require_relative 'quantize'
require_relative 'tags'
require_relative 'trace_middleware'

module Datadog
  module Tracing
    module Contrib
      module Redis
        # Instrumentation for Redis < 5
        module Instrumentation
          def self.included(base)
            base.prepend(InstanceMethods)
          end

          # InstanceMethods - implementing instrumentation
          module InstanceMethods
            def call(*args, &block)
              TraceMiddleware.call(self, args[0], service_name, command_args?) { super }
            end

            def call_pipeline(*args, &block)
              TraceMiddleware.call_pipelined(self, args[0].commands, service_name, command_args?) { super }
            end

            private

            def command_args?
              pinned = Datadog.configuration_for(self, :command_args)

              return pinned unless pinned.nil?

              datadog_configuration[:command_args]
            end

            def service_name
              Datadog.configuration_for(self, :service_name) ||
                datadog_configuration[:service_name]
            end

            def datadog_configuration
              Datadog.configuration.tracing[:redis, options]
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ddtrace-1.23.3 lib/datadog/tracing/contrib/redis/instrumentation.rb
ddtrace-1.23.2 lib/datadog/tracing/contrib/redis/instrumentation.rb
ddtrace-1.23.1 lib/datadog/tracing/contrib/redis/instrumentation.rb
ddtrace-1.22.0 lib/datadog/tracing/contrib/redis/instrumentation.rb
ddtrace-1.21.1 lib/datadog/tracing/contrib/redis/instrumentation.rb
ddtrace-1.21.0 lib/datadog/tracing/contrib/redis/instrumentation.rb
ddtrace-1.20.0 lib/datadog/tracing/contrib/redis/instrumentation.rb