Module: OpenTelemetry::Instrumentation::Redis::Middlewares::RedisClientInstrumentation

Defined in:
lib/opentelemetry/instrumentation/redis/middlewares/redis_client.rb

Overview

Adapter for redis-client instrumentation interface

Instance Method Summary collapse

Instance Method Details

#call(command, redis_config) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/opentelemetry/instrumentation/redis/middlewares/redis_client.rb', line 16

def call(command, redis_config)
  return super unless instrumentation.config[:trace_root_spans] || OpenTelemetry::Trace.current_span.context.valid?

  attributes = span_attributes(redis_config)

  attributes['db.statement'] = serialize_commands([command]) unless instrumentation.config[:db_statement] == :omit

  span_name = command[0].to_s.upcase
  instrumentation.tracer.in_span(span_name, attributes: attributes, kind: :client) do
    super
  end
end

#call_pipelined(commands, redis_config) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/opentelemetry/instrumentation/redis/middlewares/redis_client.rb', line 29

def call_pipelined(commands, redis_config)
  return super unless instrumentation.config[:trace_root_spans] || OpenTelemetry::Trace.current_span.context.valid?

  attributes = span_attributes(redis_config)

  attributes['db.statement'] = serialize_commands(commands) unless instrumentation.config[:db_statement] == :omit

  instrumentation.tracer.in_span('PIPELINED', attributes: attributes, kind: :client) do
    super
  end
end