Class: Readyset::Railtie

Inherits:
Rails::Railtie
  • Object
show all
Defined in:
lib/readyset/railtie.rb

Instance Method Summary collapse

Instance Method Details

#setup_query_annotatorObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/readyset/railtie.rb', line 46

def setup_query_annotator
  config.after_initialize do
    if Rails.env.development? || Rails.env.test?
      if Rails.configuration.active_record.query_log_tags_enabled
        Rails.configuration.active_record.query_log_tags ||= []
        Rails.configuration.active_record.query_log_tags << {
          destination: ->(context) do
            ActiveRecord::Base.connection_db_config.name
          end,
        }
      else
        Rails.logger.warn 'Query log tags are currently disabled.' \
          'The ReadySet gem uses these tags to display information' \
          'in the logs about whether a query was routed to ReadySet.' \
          'It is highly recommended that you enable query log tags by setting' \
          '`Rails.configuration.active_record.query_log_tags_enabled` to true to' \
          'verify that queries are being routed to ReadySet as expected.'
      end
    end
  end
end