Module: OpenTelemetry::Instrumentation::LMDB::Patches::Database

Defined in:
lib/opentelemetry/instrumentation/lmdb/patches/database.rb

Overview

Module to prepend to LMDB::Database for instrumentation

Constant Summary collapse

STATEMENT_MAX_LENGTH =
500

Instance Method Summary collapse

Instance Method Details

#clearObject



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/opentelemetry/instrumentation/lmdb/patches/database.rb', line 53

def clear
  attributes = {
    'db.system' => 'lmdb',
    'db.statement' => 'CLEAR'
  }
  attributes['peer.service'] = config[:peer_service] if config[:peer_service]

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

#delete(key, value = nil) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/opentelemetry/instrumentation/lmdb/patches/database.rb', line 29

def delete(key, value = nil)
  attributes = {
    'db.system' => 'lmdb',
    'db.statement' => formatted_statement('DELETE', "DELETE #{key} #{value}".strip)
  }
  attributes['peer.service'] = config[:peer_service] if config[:peer_service]

  tracer.in_span("DELETE #{key}", attributes: attributes, kind: :client) do
    super
  end
end

#get(key) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/opentelemetry/instrumentation/lmdb/patches/database.rb', line 17

def get(key)
  attributes = {
    'db.system' => 'lmdb',
    'db.statement' => formatted_statement('GET', "GET #{key}")
  }
  attributes['peer.service'] = config[:peer_service] if config[:peer_service]

  tracer.in_span("GET #{key}", attributes: attributes, kind: :client) do
    super
  end
end

#put(key, value) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/opentelemetry/instrumentation/lmdb/patches/database.rb', line 41

def put(key, value)
  attributes = {
    'db.system' => 'lmdb',
    'db.statement' => formatted_statement('PUT', "PUT #{key} #{value}")
  }
  attributes['peer.service'] = config[:peer_service] if config[:peer_service]

  tracer.in_span("PUT #{key}", attributes: attributes, kind: :client) do
    super
  end
end