No commit activity in last 3 years
No release in over 3 years
Append query caller to each ActiveRecord's query log.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.12
~> 10.0

Runtime

>= 0
 Project Readme

Arproxy::QueryCallerLocationAnnotator

Build Status Gem Version

Append query caller method to each ActiveRecord's query log like:

User Load (0.3ms)  SELECT  `users`.* FROM `users` ORDER BY `users`.`id` ASC LIMIT 1 /* app/models/user.rb:3 `xxx` */

This library was originally written by Takatoshi Maeda (@TakatoshiMaeda on GitHub).

Installation

Add this line to your application's Gemfile:

gem 'arproxy-query_caller_location_annotator'

And then execute:

$ bundle

Usage

arproxy-query_caller_location_annotator will be setup automatically if you use mysql2 adapter. You can disable it by specifying env var as DISABLE_QUERY_LOCATION_ANNOTATE=1.

If you want to setup manually, you can change Gemfile to require: false then write a initializer by hand:

# In config/initializers/arpoxy.rb
require 'arproxy/query_caller_location_annotator/proxy'

if ::Rails.env.development? || ::Rails.env.test?
  ::Arproxy.configure do |config|
    config.adapter = 'postgresql' # Your database adapter
    config.use ::Arproxy::QueryCallerLocationAnnotator::Proxy
  end

  ::ActiveSupport.on_load :active_record do
    ::Arproxy.enable!
  end
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/taiki45/arproxy-query_caller_location_annotator.

License

The gem is available as open source under the terms of the MIT License.