Module: Datadog::Tracing::Contrib::Redis::TraceMiddleware

Defined in:
lib/datadog/tracing/contrib/redis/trace_middleware.rb

Overview

Instrumentation for Redis 5+

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(client, command, service_name, command_args) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/datadog/tracing/contrib/redis/trace_middleware.rb', line 25

def call(client, command, service_name, command_args)
  Tracing.trace(Redis::Ext::SPAN_COMMAND, type: Redis::Ext::TYPE, service: service_name) do |span|
    raw_command = get_command(command, true)
    span.resource = command_args ? raw_command : get_command(command, false)

    Contrib::Redis::Tags.set_common_tags(client, span, raw_command)

    yield
  end
end

.call_pipelined(client, commands, service_name, command_args) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/datadog/tracing/contrib/redis/trace_middleware.rb', line 36

def call_pipelined(client, commands, service_name, command_args)
  Tracing.trace(Redis::Ext::SPAN_COMMAND, type: Redis::Ext::TYPE, service: service_name) do |span|
    raw_command = get_pipeline_commands(commands, true)
    span.resource = command_args ? raw_command : get_pipeline_commands(commands, false)

    span.set_metric Contrib::Redis::Ext::METRIC_PIPELINE_LEN, commands.length

    Contrib::Redis::Tags.set_common_tags(client, span, raw_command)

    yield
  end
end

Instance Method Details

#call(command, redis_config) ⇒ Object

Instruments RedisClient::ConnectionMixin#call.



13
14
15
16
# File 'lib/datadog/tracing/contrib/redis/trace_middleware.rb', line 13

def call(command, redis_config)
  config = resolve(redis_config)
  TraceMiddleware.call(redis_config, command, config[:service_name], config[:command_args]) { super }
end

#call_pipelined(commands, redis_config) ⇒ Object

Instruments RedisClient::ConnectionMixin#call_pipelined.



19
20
21
22
# File 'lib/datadog/tracing/contrib/redis/trace_middleware.rb', line 19

def call_pipelined(commands, redis_config)
  config = resolve(redis_config)
  TraceMiddleware.call_pipelined(redis_config, commands, config[:service_name], config[:command_args]) { super }
end