Sha256: a00b4da979633c42d0d2cb259c496acef650a276e418c1685ce35815c9a5749b

Contents?: true

Size: 960 Bytes

Versions: 5

Compression:

Stored size: 960 Bytes

Contents

module Datadog
  module Contrib
    module ActiveRecord
      module Configuration
        # 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.
        module MakaraResolver
          def normalize_for_config(active_record_config)
            hash = super
            hash[:makara_role] = active_record_config[:makara_role]
            hash
          end

          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
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ddtrace-0.51.1 lib/ddtrace/contrib/active_record/configuration/makara_resolver.rb
ddtrace-0.51.0 lib/ddtrace/contrib/active_record/configuration/makara_resolver.rb
ddtrace-0.50.0 lib/ddtrace/contrib/active_record/configuration/makara_resolver.rb
ddtrace-0.49.0 lib/ddtrace/contrib/active_record/configuration/makara_resolver.rb
ddtrace-0.48.0 lib/ddtrace/contrib/active_record/configuration/makara_resolver.rb