module OpenTelemetry::Instrumentation::LMDB::Patches::Database
Module to prepend to LMDB::Database for instrumentation
Constants
- STATEMENT_MAX_LENGTH
Public Instance Methods
clear()
click to toggle source
Calls superclass method
# File lib/opentelemetry/instrumentation/lmdb/patches/database.rb, line 47 def clear attributes = { 'db.system' => 'lmdb' } attributes['db.statement'] = 'CLEAR' if config[:db_statement] == :include 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)
click to toggle source
Calls superclass method
# File lib/opentelemetry/instrumentation/lmdb/patches/database.rb, line 27 def delete(key, value = nil) attributes = { 'db.system' => 'lmdb' } attributes['db.statement'] = formatted_statement('DELETE', "DELETE #{key} #{value}".strip) if config[:db_statement] == :include 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)
click to toggle source
Calls superclass method
# File lib/opentelemetry/instrumentation/lmdb/patches/database.rb, line 17 def get(key) attributes = { 'db.system' => 'lmdb' } attributes['db.statement'] = formatted_statement('GET', "GET #{key}") if config[:db_statement] == :include 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)
click to toggle source
Calls superclass method
# File lib/opentelemetry/instrumentation/lmdb/patches/database.rb, line 37 def put(key, value) attributes = { 'db.system' => 'lmdb' } attributes['db.statement'] = formatted_statement('PUT', "PUT #{key} #{value}") if config[:db_statement] == :include attributes['peer.service'] = config[:peer_service] if config[:peer_service] tracer.in_span("PUT #{key}", attributes: attributes, kind: :client) do super end end
Private Instance Methods
config()
click to toggle source
# File lib/opentelemetry/instrumentation/lmdb/patches/database.rb, line 67 def config LMDB::Instrumentation.instance.config end
formatted_statement(operation, statement)
click to toggle source
# File lib/opentelemetry/instrumentation/lmdb/patches/database.rb, line 59 def formatted_statement(operation, statement) statement = OpenTelemetry::Common::Utilities.truncate(statement, STATEMENT_MAX_LENGTH) OpenTelemetry::Common::Utilities.utf8_encode(statement) rescue StandardError => e OpenTelemetry.logger.debug("non formattable LMDB statement #{statement}: #{e}") "#{operation} BLOB (OMITTED)" end
tracer()
click to toggle source
# File lib/opentelemetry/instrumentation/lmdb/patches/database.rb, line 71 def tracer LMDB::Instrumentation.instance.tracer end