Module: Datadog::Contrib::ActiveRecord::Configuration::MakaraResolver

Included in:
Resolver
Defined in:
lib/ddtrace/contrib/active_record/configuration/makara_resolver.rb

Overview

The makara gem has the concept of role, which can be inferred from the configuration name, in the form of: master/0, replica/0, replica/1, etc. The first part of this string is the database role.

This allows the matching of a connection based on its role, instead of connection-specific information.

Instance Method Summary collapse

Instance Method Details

#normalize_for_config(active_record_config) ⇒ Object



14
15
16
17
18
# File 'lib/ddtrace/contrib/active_record/configuration/makara_resolver.rb', line 14

def normalize_for_config(active_record_config)
  hash = super
  hash[:makara_role] = active_record_config[:makara_role]
  hash
end

#normalize_for_resolve(active_record_config) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/ddtrace/contrib/active_record/configuration/makara_resolver.rb', line 20

def normalize_for_resolve(active_record_config)
  hash = super

  hash[:makara_role] = active_record_config[:name].split('/')[0].to_s if active_record_config[:name].is_a?(String)

  hash
end