testoscope 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 48ce691579625e8c4b15011a87d40899d4c51452
4
- data.tar.gz: 183f29ac7bd2e766d43c78eb051f42c77e67444b
2
+ SHA256:
3
+ metadata.gz: 3b8d037184ba7ff1c1cd5e14d0dbeba4a9abf6787c83fd433a11701851f42059
4
+ data.tar.gz: 9e60451e44a9b04f4d14c0bb1142bc1bcb3635d3f62b5e524d9518ace953a6ef
5
5
  SHA512:
6
- metadata.gz: 1739040d166c49b7c81b1d8dd50991b4913a12446161ae0cdfbed0cd4d287b8a11af11e64810caac6bee4d9c47e2abeb24d6bf303aede27ca297a3a5898affe1
7
- data.tar.gz: 4f565be713d29e50e7929bd52852848a6ca4b7ad5d9fbbea22c352f3a2838b9f0ab059e4350142927d1ba273bf289c58bc64e596829305895c9850be57dddb72
6
+ metadata.gz: 87e2e7cbe4068255d34828bce780296f765c8dd48ba19230a8e7f352783ab9948aae1d3de5cf9570e09f08c14bc74a7ffea862b0684ebe15b86e15da19bf724d
7
+ data.tar.gz: f5aefb8afd68f1830c51f5dabd0960297a7907a6011a0672befb198e6dd65a3fe16e62f968751493c489f05c937afef7bcb8d2da0ea273f1fab6f593e34d8ad6
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ # 0.1.6
2
+
3
+ * can run EXPLAIN queries with testoscope enabled
4
+ * add two more regexp on used index
data/README.md CHANGED
@@ -42,7 +42,7 @@ and in ORM it doesn't look alarming:
42
42
 
43
43
  sub_tags.where( name: names )
44
44
 
45
- So when names is empty, we get a dummy request.
45
+ But when names is empty, we get a dummy request.
46
46
 
47
47
  They are not a big deal from a performance perspective,
48
48
  but you are occupying DB connection pool and cluttering your channel with empty noise.
@@ -61,21 +61,21 @@ In either cases you may have a problem, but also may not.
61
61
 
62
62
  ### How it works?
63
63
  Testoscope hooks to exec_query of a connection adapter,
64
- for all queries runs them two times:
65
- first with EXPLAIN and analyze it,
66
- and the second - is for original a caller purpose.
64
+ when sql query reach exec_query it runs two times:
65
+ first with EXPLAIN for tstoscope to analyze,
66
+ and the second - for original a caller purpose.
67
67
 
68
- After achieving explain result, it simply search for configured unintended behaviour markers,
68
+ After retrieving explain result, testoscope search for specified unintended behaviour markers,
69
69
  like a Seq Scan substring in Postgres QUERY PLAN explained, and also collects indexes used by all queries for a final summary.
70
70
 
71
71
  ### Unintended Behaviours
72
- By default unintended behaviours are preconfigured for PosgtreSQL and all tables:
72
+ By default markers are preconfigured for PosgtreSQL and full list of tables:
73
73
 
74
74
  config.unintened_key_words = ['Seq Scan', 'One-Time Filter']
75
75
  config.tables = :all
76
76
 
77
77
  But you can set any regexp you want to track inside EXPLAIN results,
78
- and also you can track not all tables, but only specified ones:
78
+ and also you can track partial list of tables:
79
79
 
80
80
  config.tables = ['cards', 'users']
81
81
 
@@ -85,32 +85,42 @@ and also you can track not all tables, but only specified ones:
85
85
  Add this line to your application's Gemfile:
86
86
 
87
87
  ```ruby
88
- gem 'testoscope'
88
+ group :test do
89
+ gem 'testoscope'
90
+ end
91
+
89
92
  ```
90
93
 
91
94
  And then execute:
92
95
 
93
96
  $ bundle
94
-
95
- Or install it yourself as:
96
-
97
- $ gem install testoscope
98
-
97
+
99
98
  ## Usage
100
99
 
101
100
  In test_helper.rb:
102
101
 
103
102
  require 'testoscope'
104
103
 
105
- #since doubling all requests to DB is not free,
106
- #you may use ENV variable to run on demand
104
+ # since doubling all requests to DB is not free,
105
+ # you may use ENV variable to run on demand
107
106
  if ENV[:RUN_TESTOSCOPE]
108
107
  Testoscope.configure { |c|
108
+ # include only trace from folders
109
109
  c.back_trace_paths = [Rails.root.to_s]
110
+
111
+ # additionaly exclude subfolders
110
112
  c.back_trace_exclude_paths = ["#{Rails.root.to_s}/test", "#{Rails.root.to_s}/spec"]
113
+
114
+ # unintended behaviour markers
111
115
  c.unintened_key_words = ['Seq Scan', 'One-Time Filter']
116
+
117
+ # set true to raise error on unintended behaviour
112
118
  c.raise_when_unintended = false
119
+
120
+ # true to analyze everything, false to analize only by demand using suspend_global_analyze
113
121
  c.analyze = true
122
+
123
+ # :all - to complete list, or array of specific table names: [ 'users', 'comments' ... ]
114
124
  c.tables = :all
115
125
  }
116
126
 
data/lib/testoscope.rb CHANGED
@@ -114,7 +114,8 @@ module Testoscope
114
114
  self.add_unintended_behaviour( sql, explain, app_trace )
115
115
  end
116
116
 
117
- explain.scan(/Index Scan using \w+/).each{|found| add_index_used(sql, explain, found[17..-1]) }
117
+ explain.scan(/Index Scan using (\w+)|Index Scan on (\w+)|Index Scan Backward using (\w+)/)
118
+ .each{|found| add_index_used(sql, explain, found.compact.first ) }
118
119
  end
119
120
  end
120
121
 
@@ -127,7 +128,7 @@ module Testoscope
127
128
  module AdapterUpgrade
128
129
  def exec_query(sql, name = "SQL", binds = [], prepare: false)
129
130
  Testoscope.analyze(sql) {
130
- super( 'EXPLAIN ' + sql, "EXPLAIN", binds, prepare: false)
131
+ super( sql['EXPLAIN'] ? sql : 'EXPLAIN ' + sql, "EXPLAIN", binds, prepare: false)
131
132
  }
132
133
  super( sql, name, binds, prepare: prepare )
133
134
  end
@@ -1,3 +1,3 @@
1
1
  module Testoscope
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testoscope
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - alekseyl
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-20 00:00:00.000000000 Z
11
+ date: 2018-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,6 +96,7 @@ files:
96
96
  - ".idea/testoscope.iml"
97
97
  - ".idea/workspace.xml"
98
98
  - ".travis.yml"
99
+ - CHANGELOG.md
99
100
  - Gemfile
100
101
  - LICENSE.txt
101
102
  - README.md
@@ -127,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
128
  version: '0'
128
129
  requirements: []
129
130
  rubyforge_project:
130
- rubygems_version: 2.6.13
131
+ rubygems_version: 2.7.6
131
132
  signing_key:
132
133
  specification_version: 4
133
134
  summary: This is simple and nice tool to inspect how application operates with current