Module: OpenTelemetry::Instrumentation::Dalli::Patches::Server

Defined in:
lib/opentelemetry/instrumentation/dalli/patches/server.rb

Overview

Module to prepend to Dalli::Server (or Dalli::Protocol::Binary in 3.0+) for instrumentation

Instance Method Summary collapse

Instance Method Details

#request(op, *args) ⇒ Object

rubocop:disable Naming/MethodParameterName



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/opentelemetry/instrumentation/dalli/patches/server.rb', line 13

def request(op, *args) # rubocop:disable Naming/MethodParameterName
  operation = Utils.opname(op, multi?)
  attributes = {
    'db.system' => 'memcached',
    'db.operation' => operation,
    'net.peer.name' => hostname,
    'net.peer.port' => port
  }
  if config[:db_statement] == :include
    attributes['db.statement'] = Utils.format_command(operation, args)
  elsif config[:db_statement] == :obfuscate
    attributes['db.statement'] = "#{operation} ?"
  end

  attributes['peer.service'] = config[:peer_service] if config[:peer_service]
  tracer.in_span(operation, attributes: attributes, kind: :client) do
    super
  end
end