rack-insight 0.5.12 → 0.5.13
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/CHANGELOG +8 -1
- data/Gemfile.lock +1 -1
- data/README.md +37 -16
- data/lib/rack/insight/config.rb +7 -1
- data/lib/rack/insight/database.rb +16 -1
- data/lib/rack/insight/panels/cache_panel.rb +0 -2
- data/lib/rack/insight/panels/log_panel.rb +24 -8
- data/lib/rack/insight/version.rb +1 -1
- data/lib/rack/insight/views/panels/log.html.erb +1 -1
- metadata +1 -1
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
== HEAD
|
2
2
|
|
3
|
+
* New Features
|
4
|
+
|
5
|
+
* Panel level configuration options for all panels, including extension gems.
|
6
|
+
Currently this is implemented in the log_panel, and configured as:
|
7
|
+
Rack::Insight::Config.configure do |config|
|
8
|
+
config[:panel_configs][:log_panel] = {:watch => {'Logger' => :add}}
|
9
|
+
end
|
10
|
+
* Count number of Log Entries
|
3
11
|
|
4
12
|
== 0.5.12 / 2012-09-10
|
5
13
|
|
@@ -7,7 +15,6 @@
|
|
7
15
|
|
8
16
|
* Improving documentation by Peter Boling
|
9
17
|
|
10
|
-
|
11
18
|
* New Features
|
12
19
|
|
13
20
|
* persistent toolbar position by Alif Rachmawadi
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
Rack::Insight
|
2
|
-
|
3
|
-
|
4
|
-
Rack::Insight began life as an fork of Logical::Insight by LRDesign.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
=============
|
3
|
+
|
4
|
+
Rack::Insight began life as an fork of Logical::Insight by LRDesign.
|
5
|
+
|
6
|
+
* I started a fork because:
|
7
|
+
* LogicalInsight was namespaced as "Insight"
|
8
|
+
* Causing namespace collisions everywhere I have an Insight model. I had to re-namespace all the code.
|
9
|
+
* I also needed to build a few extension gems with additional panels, which didn't fully work in LI
|
10
|
+
* Added the Config class to allow for custom panel load paths
|
11
|
+
and many other extensions that don't work in the *use Middleware* declaration.
|
12
|
+
|
13
|
+
It should be *even* easier to extend than LogicalInsight was, because extension gems can access the Config class
|
11
14
|
and truly bolt-on cleanly.
|
12
15
|
|
13
16
|
Having made really significant architectural changes, I'll be keeping Rack::Insight
|
14
|
-
a separate project for the
|
17
|
+
a separate project for the foreseeable future.
|
15
18
|
|
16
|
-
* Forked From: [logical-insight](http://github.com/LRDesign/logical-insight)
|
19
|
+
* Forked From: [logical-insight](http://github.com/LRDesign/logical-insight)
|
17
20
|
* Which Was Forked From: [rack-bug](http://github.com/brynary/rack-bug)
|
18
21
|
|
19
22
|
Description
|
@@ -33,12 +36,12 @@ Features
|
|
33
36
|
* Rails Info
|
34
37
|
* Timer
|
35
38
|
* Request Variables
|
36
|
-
* SQL
|
37
|
-
* Active Record
|
38
39
|
* Cache
|
39
40
|
* Templates
|
40
|
-
* Log
|
41
|
+
* Log (can configure which loggers to watch!)
|
41
42
|
* Memory
|
43
|
+
* SQL (Failing specs, and I don't use it, someone please pull me a fix!)
|
44
|
+
* Active Record (Failing specs, and I don't use it, someone please pull me a fix!)
|
42
45
|
* Other bundled panels:
|
43
46
|
* Redis
|
44
47
|
* Speedtracer
|
@@ -49,7 +52,7 @@ Features
|
|
49
52
|
* Consistent interface to instrument application code
|
50
53
|
* Consistent timing across panels
|
51
54
|
* Easy to add sub-applications for more detailed reports (c.f. SQLPanel)
|
52
|
-
*
|
55
|
+
* Ask me (pboling) if you need help with this.
|
53
56
|
|
54
57
|
Rails quick start
|
55
58
|
---------------------------
|
@@ -105,6 +108,24 @@ Options:
|
|
105
108
|
:panel_load_paths => [File::join('rack', 'insight', 'panels')] (default)
|
106
109
|
See *Configuring custom panels* section for example usage
|
107
110
|
|
111
|
+
:panel_configs => This is a nested config, se below:
|
112
|
+
|
113
|
+
Panel level configuration options for all panels, including extension gems.
|
114
|
+
Currently this is implemented in the log_panel, and configured as:
|
115
|
+
|
116
|
+
Rack::Insight::Config.configure do |config|
|
117
|
+
config[:panel_configs][:log_panel] = {:watch => {'Logger' => :add}}
|
118
|
+
end
|
119
|
+
|
120
|
+
Example: If you want all of your log statements in Rails to be traced twice by Rack::Insight,
|
121
|
+
this will do that because ActiveSupport::BufferedLogger utilizes Logger under the hood:
|
122
|
+
|
123
|
+
config[:panel_configs][:log_panel] = {:watch => {
|
124
|
+
"ActiveSupport::BufferedLogger" => :add,
|
125
|
+
"Logger" => :add
|
126
|
+
}}
|
127
|
+
|
128
|
+
|
108
129
|
Configure Middleware
|
109
130
|
--------------------
|
110
131
|
|
@@ -207,7 +228,7 @@ and Rack::Cache
|
|
207
228
|
License
|
208
229
|
-------
|
209
230
|
|
210
|
-
See LICENSE in this directory.
|
231
|
+
MIT. See LICENSE in this directory.
|
211
232
|
|
212
233
|
Notes
|
213
234
|
-----
|
data/lib/rack/insight/config.rb
CHANGED
@@ -9,6 +9,7 @@ module Rack::Insight
|
|
9
9
|
@verbosity = true
|
10
10
|
@rails_log_copy = true
|
11
11
|
@filtered_backtrace = true
|
12
|
+
@panel_configs = {}
|
12
13
|
|
13
14
|
DEFAULTS = {
|
14
15
|
# You can augment or replace the default set of panel load paths.
|
@@ -26,7 +27,8 @@ module Rack::Insight
|
|
26
27
|
:rails_log_copy => @rails_log_copy, # Only has effect when logger is the Rack::Insight::Logger, or a logger behaving like it
|
27
28
|
# Can set a specific verbosity: Rack::Insight::Logging::VERBOSITY[:debug]
|
28
29
|
:verbosity => @verbosity, # true is equivalent to relying soley on the log level of each logged message
|
29
|
-
:filtered_backtrace => @filtered_backtrace # Full backtraces, or filtered ones?
|
30
|
+
:filtered_backtrace => @filtered_backtrace, # Full backtraces, or filtered ones?
|
31
|
+
:panel_configs => @panel_configs # Allow specific panels to have their own configurations, and make it extensible
|
30
32
|
}
|
31
33
|
|
32
34
|
@config ||= DEFAULTS
|
@@ -38,9 +40,13 @@ module Rack::Insight
|
|
38
40
|
@log_file = config[:log_file]
|
39
41
|
@verbosity = config[:verbosity]
|
40
42
|
@filtered_backtrace = config[:filtered_backtrace]
|
43
|
+
@panel_configs = config[:panel_configs]
|
41
44
|
unless config[:panel_load_paths].kind_of?(Array)
|
42
45
|
raise "Rack::Insight::Config.config[:panel_load_paths] is invalid: Expected kind of Array but got #{config[:panel_load_paths].class}"
|
43
46
|
end
|
47
|
+
unless config[:panel_configs].kind_of?(Hash)
|
48
|
+
raise "Rack::Insight::Config.config[:panel_configs] is invalid: Expected kind of Hash but got #{config[:panel_configs].class}"
|
49
|
+
end
|
44
50
|
end
|
45
51
|
|
46
52
|
def self.logger
|
@@ -30,7 +30,10 @@ module Rack::Insight
|
|
30
30
|
def retrieve(request_id)
|
31
31
|
@table.for_request(request_id)
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
|
+
def count(request_id)
|
35
|
+
@table.count_for_request(request_id)
|
36
|
+
end
|
34
37
|
|
35
38
|
def table_length
|
36
39
|
@table.length
|
@@ -107,6 +110,10 @@ module Rack::Insight
|
|
107
110
|
execute("select #{which_sql} from #@table_name where #{condition_sql}")
|
108
111
|
end
|
109
112
|
|
113
|
+
def count(condition_sql)
|
114
|
+
execute("select count(*) from #@table_name where #{condition_sql}")
|
115
|
+
end
|
116
|
+
|
110
117
|
def fields_sql
|
111
118
|
"#{@keys.join(",")}"
|
112
119
|
end
|
@@ -179,10 +186,18 @@ module Rack::Insight
|
|
179
186
|
select("value", key_sql).map{|value| decode_value(value.first)}
|
180
187
|
end
|
181
188
|
|
189
|
+
def count_entries(key_sql)
|
190
|
+
count(key_sql).first.first
|
191
|
+
end
|
192
|
+
|
182
193
|
def for_request(id)
|
183
194
|
retrieve("request_id = #{id}")
|
184
195
|
end
|
185
196
|
|
197
|
+
def count_for_request(id)
|
198
|
+
count_entries("request_id = #{id}")
|
199
|
+
end
|
200
|
+
|
186
201
|
def to_a
|
187
202
|
super.map do |row|
|
188
203
|
row[-1] = decode_value(row[-1])
|
@@ -57,8 +57,6 @@ module Rack::Insight
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def content_for_request(number)
|
60
|
-
# TODO: What is this syntax with the double {{}}?
|
61
|
-
logger.debug{{ :req_num => number }} if verbose(:debug)
|
62
60
|
stats = retrieve(number).first
|
63
61
|
render_template "panels/cache", :stats => stats
|
64
62
|
end
|
@@ -23,12 +23,27 @@ module Rack::Insight
|
|
23
23
|
|
24
24
|
def initialize(app)
|
25
25
|
probe(self) do
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
if !Rack::Insight::Config.config[:panel_configs][:log_panel].respond_to?(:[])
|
27
|
+
# Trying to be smart...
|
28
|
+
if defined?(ActiveSupport)
|
29
|
+
instrument "ActiveSupport::BufferedLogger" do
|
30
|
+
instance_probe :add
|
31
|
+
end
|
32
|
+
else
|
33
|
+
instrument "Logger" do
|
34
|
+
instance_probe :add
|
35
|
+
end
|
36
|
+
end
|
37
|
+
else
|
38
|
+
# User has explicitly declared what log classes to monitor:
|
39
|
+
# Rack::Insight::Config.configure do |config|
|
40
|
+
# config[:panel_configs][:log_panel] = {:watch => {'Logger' => :add}}
|
41
|
+
# end
|
42
|
+
Rack::Insight::Config.config[:panel_configs][:log_panel][:watch].each do |klass, method_probe|
|
43
|
+
instrument klass do
|
44
|
+
instance_probe method_probe
|
45
|
+
end
|
46
|
+
end
|
32
47
|
end
|
33
48
|
end
|
34
49
|
|
@@ -41,8 +56,9 @@ module Rack::Insight
|
|
41
56
|
"log"
|
42
57
|
end
|
43
58
|
|
44
|
-
def
|
45
|
-
|
59
|
+
def heading_for_request(number)
|
60
|
+
num = count(number)
|
61
|
+
"Logs (#{num})"
|
46
62
|
end
|
47
63
|
|
48
64
|
def content_for_request(number)
|
data/lib/rack/insight/version.rb
CHANGED