Class: Instana::Exporter::Otlp::DatabaseConverter

Inherits:
BaseConverter
  • Object
show all
Defined in:
lib/instana/exporter/otlp/database_converter.rb

Overview

Converter for database spans to OTLP format

Instance Method Summary collapse

Methods inherited from BaseConverter

#convert, #initialize

Constructor Details

This class inherits a constructor from Instana::Exporter::Otlp::BaseConverter

Instance Method Details

#convert_attributesObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/instana/exporter/otlp/database_converter.rb', line 14

def convert_attributes
  attributes = {}
  data = span[:data] || {}

  convert_activerecord_attributes(attributes, data[:activerecord])
  convert_sequel_attributes(attributes, data[:sequel])
  convert_redis_attributes(attributes, data[:redis])
  convert_memcache_attributes(attributes, data[:memcache])
  convert_mongo_attributes(attributes, data[:mongo])

  attributes
end

#span_nameString

Build OTel-compliant span name for database spans

Formulas per SPAN_NAME_PATTERNS.txt Section 2:

activerecord / sequel  → "{adapter} {db}"       e.g. "mysql2 myapp"
redis                  → "redis {command}"       e.g. "redis GET"
memcache               → "memcached {command}"   e.g. "memcached get"
mongo                  → "{namespace}.{command}" e.g. "users.find"

Returns:

  • (String)

    The span name



36
37
38
39
40
41
42
43
44
# File 'lib/instana/exporter/otlp/database_converter.rb', line 36

def span_name
  data = span[:data] || {}
  activerecord_span_name(data[:activerecord]) ||
    sequel_span_name(data[:sequel]) ||
    redis_span_name(data[:redis]) ||
    memcache_span_name(data[:memcache]) ||
    mongo_span_name(data[:mongo]) ||
    super
end