active_record_query_trace 1.3 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZTBiMjU5ZWY5Y2YwMmY3ZjBlNmMyY2YyMjI4MmQ5MzU5MTEwNWY0ZA==
5
- data.tar.gz: !binary |-
6
- OTM5OWM3YWM5Y2E1OTViMTY0MDM4NWM3ODkwOWFmZmRmYzdjOGJkZg==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YmExM2U2OTk5M2U1YTA0MDM4YmI1MWFlM2E5NjhlZDkxN2EzZjEwY2M0NGFl
10
- MmY4M2Q5MDcyNzQwMDNjYjcyYjhhYTViODhmYTMwMTE4MjdlMDkxYTQyNGI2
11
- MGY0OWRmZGQ4YWM1MzhkMTg4OWUwMTUyMzVmODhhNjVjNmM3MTU=
12
- data.tar.gz: !binary |-
13
- MDk2NjUxZWViMmI0NjY4ODc4NjY3NTg5YTU4N2ViOWMyNmUzZDhkZTFkZDNm
14
- NTMyMGJlZDg5N2YwM2Q4MWUyZmFkYjM2ZDA2OGMwYWY3MTdiNmM3MzFmODU3
15
- Y2VjZjY0YzZhZDBjOGRkYzQxMzIwZDllNDZkOTFiZmQyMzA0OWM=
2
+ SHA1:
3
+ metadata.gz: f3bf7027ae082e7dbcdebe76076e574cc666ebbe
4
+ data.tar.gz: c83658ea02bf13e42384917c5642dd60153bdbcc
5
+ SHA512:
6
+ metadata.gz: 026991c7074bf4bbaa9fa08db51d650d42ef8d2973e00e305dcd7e1332fef93336eaaf94c3626607e7f5c4caf98128b433df0c2c6ee1e664604d60879242e74c
7
+ data.tar.gz: 1447eff21be5a1a3230e7b56b5c9b9e03f663b2d3f4135d99bf3ee8124719026106415cc287830159e597a8cdcbfdb4f1c78207c6f5bae45e65d8cb2bf537270
data/HISTORY.md ADDED
@@ -0,0 +1,17 @@
1
+ ## 1.4 (2015-03-05)
2
+
3
+ Support for ignoring `ActiveRecord` cached queries that show up in the log with a `CACHE` prefix.
4
+
5
+ ```ruby
6
+ ActiveRecordQueryTrace.ignore_cached_queries = true
7
+ ```
8
+
9
+ See this Pull-Request for additional notes on how these cached queries can also be skipped from the log file:
10
+
11
+ https://github.com/ruckus/active-record-query-trace/pull/10
12
+
13
+ Thank you to @tinynumbers for this contribution.
14
+
15
+ ## < 1.3
16
+
17
+ Unavailable. Sorry, I was not keep tracking of history prior to `1.4`
data/MIT-LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,12 +1,18 @@
1
1
  Logs the source of execution of all queries to the Rails log. Helpful to track down where queries are being executed in your application, for performance optimizations most likely.
2
2
 
3
- Install
4
- -------
3
+ ## Install
4
+
5
+ Install the latest stable release:
5
6
 
6
7
  `gem install active_record_query_trace`
7
8
 
8
- Usage
9
- -----
9
+ In Rails, add it to your Gemfile, then restart the server:
10
+
11
+ ```ruby
12
+ gem 'active_record_query_trace'
13
+ ```
14
+
15
+ ##Usage
10
16
 
11
17
  Enable it in an initializer:
12
18
 
@@ -14,34 +20,39 @@ Enable it in an initializer:
14
20
  ActiveRecordQueryTrace.enabled = true
15
21
  ```
16
22
 
17
- Options
18
- _______
23
+ ## Options
19
24
 
20
- There are three levels of debug.
25
+ There are three levels of debug.
21
26
 
22
27
  1. app - includes only files in your app/ directory.
23
28
  2. full - includes files in your app as well as rails.
24
- 3. rails - alternate ouput of full backtrace, useful for debugging gems.
29
+ 3. rails - alternate output of full backtrace, useful for debugging gems.
25
30
 
26
31
  ```ruby
27
32
  ActiveRecordQueryTrace.level = :app # default
28
33
  ```
29
34
 
35
+ By default, a backtrace will be logged for every query, even cached queries that do not actually hit the database. You might find it useful not to print the backtrace for cached queries:
36
+
37
+ ```ruby
38
+ ActiveRecordQueryTrace.ignore_cached_queries
39
+ ```
40
+
30
41
  Additionally, if you are working with a large app, you may wish to limit the number of lines displayed for each query.
31
42
 
32
43
  ```ruby
33
44
  ActiveRecordQueryTrace.lines = 10 # Default is 5. Setting to 0 includes entire trace.
34
45
  ```
35
46
 
36
- Output
37
- ------
47
+ ## Output
38
48
 
39
49
  When enabled every query source will be logged like:
40
50
 
41
51
  ```
42
52
  IntuitAccount Load (1.2ms) SELECT "intuit_accounts".* FROM "intuit_accounts" WHERE "intuit_accounts"."user_id" = 20 LIMIT 1
43
- Called from: app/views/users/edit.html.haml:78:in `block in _app_views_users_edit_html_haml___1953197429694975654_70177901460360'
44
- app/views/users/edit.html.haml:16:in `_app_views_users_edit_html_haml___1953197429694975654_70177901460360'
53
+ Called from:
54
+ app/views/users/edit.html.haml:78:in `block in _app_views_users_edit_html_haml___1953197429694975654_70177901460360'
55
+ app/views/users/edit.html.haml:16:in `_app_views_users_edit_html_haml___1953197429694975654_70177901460360'
45
56
  ```
46
57
 
47
58
  Requirements
@@ -4,12 +4,11 @@ require 'version'
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = 'active_record_query_trace'
6
6
  gem.version = ActiveRecordQueryTrace::VERSION
7
-
8
7
  gem.summary = "Print stack trace of all queries to the Rails log. Helpful to find where queries are being executed in your application."
9
8
  gem.description = gem.summary
10
9
  gem.authors = ["Cody Caughlan"]
11
10
  gem.email = 'toolbag@gmail.com'
12
11
  gem.homepage = 'https://github.com/ruckus/active-record-query-trace'
13
- gem.files = Dir["**/*"]
14
-
12
+ gem.files = Dir["**/*"]
13
+ gem.license = 'MIT'
15
14
  end
@@ -6,6 +6,7 @@ module ActiveRecordQueryTrace
6
6
  attr_accessor :enabled
7
7
  attr_accessor :level
8
8
  attr_accessor :lines
9
+ attr_accessor :ignore_cached_queries
9
10
  end
10
11
 
11
12
  module ActiveRecord
@@ -16,6 +17,7 @@ module ActiveRecordQueryTrace
16
17
  ActiveRecordQueryTrace.enabled = false
17
18
  ActiveRecordQueryTrace.level = :app
18
19
  ActiveRecordQueryTrace.lines = 5
20
+ ActiveRecordQueryTrace.ignore_cached_queries = false
19
21
  end
20
22
 
21
23
  def sql(event)
@@ -28,7 +30,11 @@ module ActiveRecordQueryTrace
28
30
  end
29
31
  end
30
32
 
31
- debug(color('Called from: ', MAGENTA, true) + clean_trace(caller)[index].join("\n "))
33
+ payload = event.payload
34
+ return if payload[:name] == 'SCHEMA'
35
+ return if ActiveRecordQueryTrace.ignore_cached_queries && payload[:name] == 'CACHE'
36
+
37
+ debug(color("Called from: \n ", MAGENTA, true) + clean_trace(caller)[index].join("\n "))
32
38
  end
33
39
  end
34
40
 
@@ -41,6 +47,8 @@ module ActiveRecordQueryTrace
41
47
  when :app
42
48
  Rails.backtrace_cleaner.add_silencer { |line| not line =~ /^app/ }
43
49
  Rails.backtrace_cleaner.clean(trace)
50
+ else
51
+ raise "Invalid ActiveRecordQueryTrace.level value '#{ActiveRecordQueryTrace.level}' - should be :full, :rails, or :app"
44
52
  end
45
53
  end
46
54
 
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordQueryTrace
2
- VERSION = '1.3'
2
+ VERSION = '1.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_query_trace
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.3'
4
+ version: '1.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Caughlan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-16 00:00:00.000000000 Z
11
+ date: 2015-03-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Print stack trace of all queries to the Rails log. Helpful to find where
14
14
  queries are being executed in your application.
@@ -18,11 +18,14 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - active_record_query_trace.gemspec
21
+ - HISTORY.md
21
22
  - lib/active_record_query_trace.rb
22
23
  - lib/version.rb
24
+ - MIT-LICENSE
23
25
  - README.md
24
26
  homepage: https://github.com/ruckus/active-record-query-trace
25
- licenses: []
27
+ licenses:
28
+ - MIT
26
29
  metadata: {}
27
30
  post_install_message:
28
31
  rdoc_options: []
@@ -30,19 +33,20 @@ require_paths:
30
33
  - lib
31
34
  required_ruby_version: !ruby/object:Gem::Requirement
32
35
  requirements:
33
- - - ! '>='
36
+ - - '>='
34
37
  - !ruby/object:Gem::Version
35
38
  version: '0'
36
39
  required_rubygems_version: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - ! '>='
41
+ - - '>='
39
42
  - !ruby/object:Gem::Version
40
43
  version: '0'
41
44
  requirements: []
42
45
  rubyforge_project:
43
- rubygems_version: 2.0.5
46
+ rubygems_version: 2.0.6
44
47
  signing_key:
45
48
  specification_version: 4
46
49
  summary: Print stack trace of all queries to the Rails log. Helpful to find where
47
50
  queries are being executed in your application.
48
51
  test_files: []
52
+ has_rdoc: