instacart / makara

A Read-Write Proxy for Connections; Also provides an ActiveRecord adapter.

Home Page:http://tech.taskrabbit.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

In development: makara hides the query logs references

blocknotes opened this issue · comments

Nice gem!

I have just noticed the following behaviour: I'm in development locally in a project and I haven't the makara subconfig in database.yml - the queries are proxied anyway by makara. This could be fine but it's hiding the real code line that produced a specific query (related to config.active_record.verbose_query_logs = true).

Ex.

User Load (1.2ms)  SELECT * FROM users
 /.../bundler/gems/makara-f9fce5fe68ab/lib/makara/logging/subscriber.rb:13

Is is possible to override this behaviour in some way?
Otherwise, is it possible to turn off makara with some config option?

Some extra details: this is probably an uncommon scenario because we have a Rails 5.2 application which is not in the root of the project and it looks like that we have a conflict with the AR ignore_callback method. Reference here.

In the end, I decided to override that method in a non-versioned custom initializer for development:

Rails.application.config.after_initialize do |app|
  puts '- ActiveRecord::LogSubscriber - ignored_callstack (private) - for Rails 5.2.x + Makara'
  ActiveRecord::LogSubscriber.log_subscribers.each do |log_subscriber|
    log_subscriber.class_eval do
      def ignored_callstack(path)
        super || path.start_with?(RbConfig::CONFIG["libdir"])
      end
    end
  end
end