Module: Datadog::Tracing::Contrib::Redis::Patcher

Includes:
Patcher
Defined in:
lib/datadog/tracing/contrib/redis/patcher.rb

Overview

Patcher enables patching of ‘redis’ module.

Defined Under Namespace

Modules: DatadogPinPatch, NotSupportedNoticePatch

Class Method Summary collapse

Methods included from Patcher

included

Class Method Details

.default_tagsObject



62
63
64
65
66
67
# File 'lib/datadog/tracing/contrib/redis/patcher.rb', line 62

def default_tags
  [].tap do |tags|
    tags << "target_redis_version:#{Integration.redis_version}"               if Integration.redis_version
    tags << "target_redis_client_version:#{Integration.redis_client_version}" if Integration.redis_client_version
  end
end

.patchObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/datadog/tracing/contrib/redis/patcher.rb', line 69

def patch
  # Redis 5+ extracts RedisClient to its own gem and provide instrumentation interface
  if Integration.redis_client_compatible?
    require_relative 'trace_middleware'

    ::RedisClient.register(TraceMiddleware)
  end

  if Integration.redis_compatible?
    if Integration.redis_version < Gem::Version.new('5.0.0')
      require_relative 'instrumentation'

      ::Redis.include(DatadogPinPatch)
      ::Redis::Client.include(Instrumentation)
    else # warn about non-supported configure_onto usage
      ::Redis.include(NotSupportedNoticePatch)
    end
  end
end