rack-insight 0.5.13 → 0.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +14 -0
- data/Gemfile.lock +1 -1
- data/lib/rack/insight/config.rb +27 -2
- data/lib/rack/insight/database.rb +12 -1
- data/lib/rack/insight/instrumentation/client.rb +1 -0
- data/lib/rack/insight/panel.rb +174 -5
- data/lib/rack/insight/panels/active_record_panel.rb +0 -15
- data/lib/rack/insight/panels/active_resource_panel.rb +0 -14
- data/lib/rack/insight/panels/cache_panel.rb +0 -25
- data/lib/rack/insight/panels/log_panel.rb +6 -25
- data/lib/rack/insight/panels/memory_panel.rb +0 -8
- data/lib/rack/insight/panels/mongo_panel.rb +2 -4
- data/lib/rack/insight/panels/rails_info_panel.rb +1 -3
- data/lib/rack/insight/panels/redis_panel.rb +2 -4
- data/lib/rack/insight/panels/request_variables_panel.rb +0 -9
- data/lib/rack/insight/panels/speedtracer_panel.rb +0 -6
- data/lib/rack/insight/panels/speedtracer_panel/trace-app.rb +5 -0
- data/lib/rack/insight/panels/sphinx_panel.rb +2 -4
- data/lib/rack/insight/panels/sql_panel.rb +0 -17
- data/lib/rack/insight/panels/templates_panel.rb +1 -14
- data/lib/rack/insight/panels/timer_panel.rb +1 -8
- data/lib/rack/insight/public/__insight__/insight.js +1 -0
- data/lib/rack/insight/version.rb +1 -1
- data/lib/rack/insight/views/headers_fragment.html.erb +1 -1
- data/lib/rack/insight/views/request_fragment.html.erb +1 -1
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
== HEAD
|
2
2
|
|
3
|
+
* New Features
|
4
|
+
|
5
|
+
* Panel level configurations for :probes are now supported by default on all panels
|
6
|
+
* Auto-magical panel names
|
7
|
+
* Auto-magical table creation (skipped with self.tableless = false in a Panel class definition)
|
8
|
+
* Under construction, or blank, panels have more scaffolding
|
9
|
+
*
|
10
|
+
|
11
|
+
== 0.5.13 / 2012-09-10
|
12
|
+
|
13
|
+
* Bug Fixes
|
14
|
+
|
15
|
+
* Fixed the double logging of anything logged with ActiveSupport::BufferedLogger (via the new :panel_configs)
|
16
|
+
|
3
17
|
* New Features
|
4
18
|
|
5
19
|
* Panel level configuration options for all panels, including extension gems.
|
data/Gemfile.lock
CHANGED
data/lib/rack/insight/config.rb
CHANGED
@@ -9,7 +9,21 @@ module Rack::Insight
|
|
9
9
|
@verbosity = true
|
10
10
|
@rails_log_copy = true
|
11
11
|
@filtered_backtrace = true
|
12
|
-
@panel_configs = {
|
12
|
+
@panel_configs = {
|
13
|
+
:active_record => {:probes => {'ActiveRecord' => [:class, :allocate]}},
|
14
|
+
:active_resource => {:probes => {'ActiveResource::Connection' => [:instance, :request]}},
|
15
|
+
:cache => {:probes => { 'Memcached' => [:instance, :decrement, :get, :increment, :set,
|
16
|
+
:add, :replace, :delete, :prepend, :append],
|
17
|
+
'MemCache' => [:instance, :decr, :get, :get_multi, :incr, :set, :add, :delete],
|
18
|
+
'Dalli::Client' => [:instance, :perform] } },
|
19
|
+
:active_record => {:probes => {'ActiveRecord' => [:class, :allocate]}},
|
20
|
+
# :log_panel => The log panel configures its probes in its initializer
|
21
|
+
:sql => {:probes => Hash[%w{ PostgreSQLAdapter MysqlAdapter SQLiteAdapter
|
22
|
+
Mysql2Adapter OracleEnhancedAdapter }.map do |adapter|
|
23
|
+
["ActiveRecord::ConnectionAdapters::#{adapter}", [:instance, :execute]]
|
24
|
+
end ] },
|
25
|
+
:templates => {:probes => {'ActionView::Template' => [:instance, :render]}}
|
26
|
+
}
|
13
27
|
|
14
28
|
DEFAULTS = {
|
15
29
|
# You can augment or replace the default set of panel load paths.
|
@@ -40,7 +54,11 @@ module Rack::Insight
|
|
40
54
|
@log_file = config[:log_file]
|
41
55
|
@verbosity = config[:verbosity]
|
42
56
|
@filtered_backtrace = config[:filtered_backtrace]
|
43
|
-
|
57
|
+
|
58
|
+
config[:panel_configs].each do |panel_name_sym, config|
|
59
|
+
set_panel_config(panel_name_sym, config)
|
60
|
+
end
|
61
|
+
|
44
62
|
unless config[:panel_load_paths].kind_of?(Array)
|
45
63
|
raise "Rack::Insight::Config.config[:panel_load_paths] is invalid: Expected kind of Array but got #{config[:panel_load_paths].class}"
|
46
64
|
end
|
@@ -49,6 +67,13 @@ module Rack::Insight
|
|
49
67
|
end
|
50
68
|
end
|
51
69
|
|
70
|
+
# To preserve :panel_configs settings from extension libraries,
|
71
|
+
# and allowing user config to override the defaults set in this, or other extension gems.
|
72
|
+
def self.set_panel_config(panel_name_sym, config)
|
73
|
+
@panel_configs[panel_name_sym].merge!(config)
|
74
|
+
self.config[:panel_configs][panel_name_sym] = @panel_configs[panel_name_sym]
|
75
|
+
end
|
76
|
+
|
52
77
|
def self.logger
|
53
78
|
@logger ||= begin
|
54
79
|
logga = self.config[:logger]
|
@@ -4,15 +4,26 @@ require 'base64'
|
|
4
4
|
|
5
5
|
module Rack::Insight
|
6
6
|
class Database
|
7
|
+
|
8
|
+
# Classes including this module must define the following structure:
|
9
|
+
# class FooBar
|
10
|
+
# include Rack::Insight::Database
|
11
|
+
# class << self
|
12
|
+
# attr_accessor :has_table
|
13
|
+
# end
|
14
|
+
# # Setting as below is only required when not using a table (Why are you including this module then?)
|
15
|
+
# # self.has_table = false
|
16
|
+
# end
|
7
17
|
module RequestDataClient
|
8
18
|
def key_sql_template(sql)
|
9
19
|
@key_sql_template = sql
|
10
20
|
end
|
11
21
|
|
12
22
|
def table_setup(name, *keys)
|
23
|
+
self.class.has_table = true
|
13
24
|
@table = DataTable.new(name, *keys)
|
14
25
|
if keys.empty?
|
15
|
-
@key_sql_template =
|
26
|
+
@key_sql_template = ''
|
16
27
|
end
|
17
28
|
end
|
18
29
|
|
data/lib/rack/insight/panel.rb
CHANGED
@@ -20,7 +20,11 @@ module Rack::Insight
|
|
20
20
|
|
21
21
|
include Rack::Insight::Logging
|
22
22
|
|
23
|
-
attr_accessor :template_root
|
23
|
+
attr_accessor :template_root, :is_probed, :has_table, :is_magic
|
24
|
+
@is_probed = false # Once a panel is probed this should be set to true
|
25
|
+
@has_table = true # default to true. Panels without tables override with self.has_table = false
|
26
|
+
@is_magic = false # check this to wrap any functionality targeted at magic panels.
|
27
|
+
|
24
28
|
def file_index
|
25
29
|
return @file_index ||= Hash.new do |h,k|
|
26
30
|
h[k] = []
|
@@ -33,10 +37,17 @@ module Rack::Insight
|
|
33
37
|
|
34
38
|
def from_file(rel_path)
|
35
39
|
old_rel, Thread::current['rack-panel_file'] = Thread::current['rack-panel_file'], rel_path
|
36
|
-
Rack::Insight::Config.config[:panel_load_paths].
|
40
|
+
load_paths_to_check = Rack::Insight::Config.config[:panel_load_paths].length
|
41
|
+
Rack::Insight::Config.config[:panel_load_paths].each_with_index do |load_path, index|
|
37
42
|
begin
|
38
43
|
require File::join(load_path, rel_path)
|
44
|
+
break # once found
|
39
45
|
rescue LoadError => e
|
46
|
+
# TODO: If probes are defined for this panel, instantiate a magic panel
|
47
|
+
# if self.has_custom_probes?
|
48
|
+
if (index + 1) == load_paths_to_check # You have failed me for the last time!
|
49
|
+
warn "Rack::Insight #{e.class}: Unable to find panel specified as '#{rel_path}'. Looked in the following :panel_load_paths: #{Rack::Insight::Config.config[:panel_load_paths].inspect}."
|
50
|
+
end
|
40
51
|
end
|
41
52
|
end
|
42
53
|
return (file_index[rel_path] - panel_exclusion)
|
@@ -91,6 +102,48 @@ module Rack::Insight
|
|
91
102
|
else
|
92
103
|
@app = app
|
93
104
|
end
|
105
|
+
|
106
|
+
# User has explicitly declared what classes/methods to probe:
|
107
|
+
# Rack::Insight::Config.configure do |config|
|
108
|
+
# config[:panel_configs][:log] = {:probes => {'Logger' => [:instance, :add] } }
|
109
|
+
# # OR EQUIVALENTLY
|
110
|
+
# config[:panel_configs][:log] = {:probes => ['Logger', :instance, :add] }
|
111
|
+
# end
|
112
|
+
panel_name = self.underscored_name.to_sym
|
113
|
+
if self.has_custom_probes?(panel_name)
|
114
|
+
custom_probes = Rack::Insight::Config.config[:panel_configs][panel_name][:probes]
|
115
|
+
if custom_probes.kind_of?(Hash)
|
116
|
+
probe(self) do
|
117
|
+
custom_probes.each do |klass, method_probes|
|
118
|
+
probe_type = method_probes.shift
|
119
|
+
instrument klass do
|
120
|
+
self.send("#{probe_type}_probe", *method_probes)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
elsif custom_probes.kind_of?(Array) && custom_probes.length >=3
|
125
|
+
probe(self) do
|
126
|
+
custom_probes.each do |probe|
|
127
|
+
klass = probe.shift
|
128
|
+
probe_type = probe.shift
|
129
|
+
instrument klass do
|
130
|
+
self.send("#{probe_type}_probe", *probe)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
else
|
135
|
+
raise "Expected Rack::Insight::Config.config[:panel_configs][#{self.as_sym.inspect}][:probes] to be a kind of Hash or an Array with length >= 3, but is a #{Rack::Insight::Config.config[:panel_configs][self.as_sym][:probes].class}"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# Setup a table for the panel unless
|
140
|
+
# 1. self.has_table = false has been set for the Panel class
|
141
|
+
# 2. class instance variable @has_table has been set to false
|
142
|
+
# 3. table_setup has already been called by the sub class' initializer
|
143
|
+
if !has_table?
|
144
|
+
table_setup(self.name)
|
145
|
+
end
|
146
|
+
#puts "Initalization Complete for #{panel_name}\n1. #{self.is_magic?} && 2. #{self.has_table?} && 3. #{self.is_probed?} 4. #{self.has_custom_probes?}"
|
94
147
|
end
|
95
148
|
|
96
149
|
def call(env)
|
@@ -113,20 +166,126 @@ module Rack::Insight
|
|
113
166
|
{}
|
114
167
|
end
|
115
168
|
|
169
|
+
def has_table?
|
170
|
+
!!self.class.has_table
|
171
|
+
end
|
172
|
+
|
173
|
+
def is_magic?
|
174
|
+
!!self.class.is_magic
|
175
|
+
end
|
176
|
+
|
116
177
|
def has_content?
|
117
178
|
true
|
118
179
|
end
|
119
180
|
|
181
|
+
def is_probed?
|
182
|
+
!!self.class.is_probed
|
183
|
+
end
|
184
|
+
|
185
|
+
def has_custom_probes?(panel_name = self.underscored_name.to_sym)
|
186
|
+
#puts "Rack::Insight::Config.config[:panel_configs][#{panel_name.inspect}]: #{Rack::Insight::Config.config[:panel_configs][panel_name].inspect}"
|
187
|
+
Rack::Insight::Config.config[:panel_configs][panel_name].respond_to?(:[]) &&
|
188
|
+
!Rack::Insight::Config.config[:panel_configs][panel_name][:probes].nil?
|
189
|
+
end
|
190
|
+
|
191
|
+
# The name informs the table name, and the panel_configs hash among other things.
|
192
|
+
# Override in subclass panels if you want a custom name
|
120
193
|
def name
|
121
|
-
|
194
|
+
self.underscored_name
|
195
|
+
end
|
196
|
+
|
197
|
+
# Mostly stolen from Rails' ActiveSupport' underscore method:
|
198
|
+
# See activesupport/lib/active_support/inflector/methods.rb, line 77
|
199
|
+
# HTTPClientPanel => http_client
|
200
|
+
# LogPanel => log
|
201
|
+
# ActiveRecordPanel => active_record
|
202
|
+
def underscored_name(word = self.class.to_s)
|
203
|
+
@underscored_name ||= begin
|
204
|
+
words = word.dup.split('::')
|
205
|
+
word = words.last
|
206
|
+
if word == 'Panel'
|
207
|
+
word = words[-2] # Panel class is Panel... and this won't do.
|
208
|
+
end
|
209
|
+
#word.gsub!(/(?:([A-Za-z\d])|^)(#{inflections.acronym_regex})(?=\b|[^a-z])/) { "#{$1}#{$1 && '_'}#{$2.downcase}" }
|
210
|
+
word.gsub!(/Panel$/,'')
|
211
|
+
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
|
212
|
+
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
213
|
+
word.tr!("-", "_")
|
214
|
+
word.downcase!
|
215
|
+
word
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def camelized_name(str = self.underscored_name)
|
220
|
+
str.split('_').map {|w| w.capitalize}.join
|
122
221
|
end
|
123
222
|
|
124
223
|
def heading_for_request(number)
|
125
|
-
|
224
|
+
if !self.has_table?
|
225
|
+
heading
|
226
|
+
else
|
227
|
+
num = count(number)
|
228
|
+
if num == 0
|
229
|
+
heading
|
230
|
+
else
|
231
|
+
"#{self.camelized_name} (#{num})"
|
232
|
+
end
|
233
|
+
end
|
234
|
+
rescue 'XXX' # no panel should need this
|
126
235
|
end
|
127
236
|
|
128
237
|
def content_for_request(number)
|
129
|
-
|
238
|
+
logger.info("Rack::Insight is using default content_for_request for #{self.class}") if verbose(:med)
|
239
|
+
if !self.has_table?
|
240
|
+
logger.info("#{self.class} is being used without a table") if verbose(:med)
|
241
|
+
content
|
242
|
+
elsif self.is_probed?
|
243
|
+
html = "<h3>#{self.camelized_name}</h3>"
|
244
|
+
invocations = retrieve(number)
|
245
|
+
if invocations.length > 0 && invocations.first.is_a?(Rack::Insight::Panel::DefaultInvocation)
|
246
|
+
html += '<table><thead><tr>'
|
247
|
+
logger.info("Rack::Insight is using magic content for #{self.class}, which is probed") if verbose(:med)
|
248
|
+
members = invocations.first.members # is a struct, so we have members, not keys
|
249
|
+
members.each do |member|
|
250
|
+
html += '<td>' << member.to_s << '</td>'
|
251
|
+
end
|
252
|
+
html += '</tr></thead><tbody>'
|
253
|
+
invocations.each do |invocation|
|
254
|
+
html += '<tr>'
|
255
|
+
members.each do |member|
|
256
|
+
html += '<td>' << invocation.send(member).inspect << '</td>'
|
257
|
+
end
|
258
|
+
html += '</tr>'
|
259
|
+
end
|
260
|
+
html += '</tbody></table>'
|
261
|
+
else
|
262
|
+
html += '<p>No Data Available</p>'
|
263
|
+
end
|
264
|
+
html
|
265
|
+
else
|
266
|
+
content
|
267
|
+
end
|
268
|
+
rescue 'XXX' #XXX: no panel should need this
|
269
|
+
end
|
270
|
+
|
271
|
+
def heading
|
272
|
+
self.camelized_name
|
273
|
+
end
|
274
|
+
|
275
|
+
def content
|
276
|
+
logger.info("Rack::Insight is using default content for #{self.class}") if verbose(:med)
|
277
|
+
html = "<h3>#{self.camelized_name}</h3>"
|
278
|
+
html += '<p>Add a content method to your panel</p>'
|
279
|
+
html
|
280
|
+
end
|
281
|
+
|
282
|
+
# Override in subclasses.
|
283
|
+
# This is to make magic classes work.
|
284
|
+
def after_detect(method_call, timing, args, result)
|
285
|
+
#puts "Default After Detect for #{self.underscored_name}: 1. #{self.is_magic?} && 2. #{self.has_table?} && 3. #{self.is_probed?}"
|
286
|
+
if self.is_magic? && self.has_table? && self.is_probed?
|
287
|
+
store(@env, DefaultInvocation.new(method_call.to_s, timing.duration, args, result))
|
288
|
+
end
|
130
289
|
end
|
131
290
|
|
132
291
|
def before(env)
|
@@ -138,6 +297,16 @@ module Rack::Insight
|
|
138
297
|
def render(template)
|
139
298
|
end
|
140
299
|
|
300
|
+
# For Magic Panels (not fully implemented)
|
301
|
+
class DefaultInvocation < Struct.new :method, :time, :args, :result
|
302
|
+
def initialize(*args)
|
303
|
+
@time = human_time(args[1])
|
304
|
+
end
|
305
|
+
def human_time(t)
|
306
|
+
"%.2fms" % (t * 1_000)
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
141
310
|
end
|
142
311
|
|
143
312
|
end
|
@@ -1,16 +1,5 @@
|
|
1
1
|
module Rack::Insight
|
2
2
|
class ActiveRecordPanel < Panel
|
3
|
-
def initialize(app)
|
4
|
-
super
|
5
|
-
|
6
|
-
table_setup("active_record")
|
7
|
-
|
8
|
-
probe(self) do
|
9
|
-
instrument "ActiveRecord::Base" do
|
10
|
-
class_probe :allocate
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
3
|
|
15
4
|
def request_start(env, start)
|
16
5
|
@records = Hash.new{ 0 }
|
@@ -24,10 +13,6 @@ module Rack::Insight
|
|
24
13
|
store(env, @records)
|
25
14
|
end
|
26
15
|
|
27
|
-
def name
|
28
|
-
"active_record"
|
29
|
-
end
|
30
|
-
|
31
16
|
def heading_for_request(number)
|
32
17
|
record = retrieve(number).first
|
33
18
|
total = record.inject(0) do |memo, (key, value)|
|
@@ -6,16 +6,6 @@ module Rack::Insight
|
|
6
6
|
#require "rack/insight/panels/sql_panel/panel_app"
|
7
7
|
#require "rack/insight/panels/sql_panel/query"
|
8
8
|
|
9
|
-
def initialize(app)
|
10
|
-
super
|
11
|
-
probe(self) do
|
12
|
-
instrument "ActiveResource::Connection" do
|
13
|
-
instance_probe :request
|
14
|
-
end
|
15
|
-
end
|
16
|
-
table_setup("active_resource_requests")
|
17
|
-
end
|
18
|
-
|
19
9
|
def after_detect(method_call, timing, arguments, results)
|
20
10
|
body = "<no body>"
|
21
11
|
if results.respond_to? :body
|
@@ -30,10 +20,6 @@ module Rack::Insight
|
|
30
20
|
end)
|
31
21
|
end
|
32
22
|
|
33
|
-
def name
|
34
|
-
"active_resource"
|
35
|
-
end
|
36
|
-
|
37
23
|
def heading_for_request(number)
|
38
24
|
queries = retrieve(number)
|
39
25
|
"ARes: #{queries.size} Queries (%.2fms)" % total_time(queries)
|
@@ -4,27 +4,6 @@ module Rack::Insight
|
|
4
4
|
require "rack/insight/panels/cache_panel/panel_app"
|
5
5
|
require "rack/insight/panels/cache_panel/stats"
|
6
6
|
|
7
|
-
def initialize(app)
|
8
|
-
super
|
9
|
-
|
10
|
-
probe(self) do
|
11
|
-
instrument("Memcached") do
|
12
|
-
instance_probe :decrement, :get, :increment, :set, :add,
|
13
|
-
:replace, :delete, :prepend, :append
|
14
|
-
end
|
15
|
-
|
16
|
-
instrument("MemCache") do
|
17
|
-
instance_probe :decr, :get, :get_multi, :incr, :set, :add, :delete
|
18
|
-
end
|
19
|
-
|
20
|
-
instrument("Dalli::Client") do
|
21
|
-
instance_probe :perform
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
table_setup("cache")
|
26
|
-
end
|
27
|
-
|
28
7
|
def request_start(env, start)
|
29
8
|
@stats = Stats.new
|
30
9
|
end
|
@@ -46,10 +25,6 @@ module Rack::Insight
|
|
46
25
|
PanelApp.new
|
47
26
|
end
|
48
27
|
|
49
|
-
def name
|
50
|
-
"cache"
|
51
|
-
end
|
52
|
-
|
53
28
|
def heading_for_request(number)
|
54
29
|
stats = retrieve(number).first
|
55
30
|
|
@@ -22,8 +22,12 @@ module Rack::Insight
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def initialize(app)
|
25
|
-
|
26
|
-
|
25
|
+
|
26
|
+
# Call super before setting up probes in case there are any custom probes configured
|
27
|
+
super # will setup custom probes
|
28
|
+
|
29
|
+
unless is_probed?
|
30
|
+
probe(self) do
|
27
31
|
# Trying to be smart...
|
28
32
|
if defined?(ActiveSupport)
|
29
33
|
instrument "ActiveSupport::BufferedLogger" do
|
@@ -34,31 +38,8 @@ module Rack::Insight
|
|
34
38
|
instance_probe :add
|
35
39
|
end
|
36
40
|
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
|
47
41
|
end
|
48
42
|
end
|
49
|
-
|
50
|
-
table_setup("log_entries")
|
51
|
-
|
52
|
-
super
|
53
|
-
end
|
54
|
-
|
55
|
-
def name
|
56
|
-
"log"
|
57
|
-
end
|
58
|
-
|
59
|
-
def heading_for_request(number)
|
60
|
-
num = count(number)
|
61
|
-
"Logs (#{num})"
|
62
43
|
end
|
63
44
|
|
64
45
|
def content_for_request(number)
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module Rack::Insight
|
2
2
|
|
3
3
|
class MemoryPanel < Panel
|
4
|
-
def initialize(app)
|
5
|
-
super
|
6
|
-
table_setup("memory_records")
|
7
|
-
end
|
8
4
|
|
9
5
|
def before(env)
|
10
6
|
@original_memory = `ps -o rss= -p #{$$}`.to_i
|
@@ -27,10 +23,6 @@ module Rack::Insight
|
|
27
23
|
false
|
28
24
|
end
|
29
25
|
|
30
|
-
def name
|
31
|
-
"Memory"
|
32
|
-
end
|
33
|
-
|
34
26
|
end
|
35
27
|
|
36
28
|
end
|
@@ -4,6 +4,8 @@ module Rack::Insight
|
|
4
4
|
require "rack/insight/panels/mongo_panel/mongo_extension"
|
5
5
|
require "rack/insight/panels/mongo_panel/stats"
|
6
6
|
|
7
|
+
self.has_table = false
|
8
|
+
|
7
9
|
def self.record(command, &block)
|
8
10
|
return block.call unless Rack::Insight.enabled?
|
9
11
|
|
@@ -22,10 +24,6 @@ module Rack::Insight
|
|
22
24
|
Thread.current["rack-insight.mongo"] ||= Stats.new
|
23
25
|
end
|
24
26
|
|
25
|
-
def name
|
26
|
-
"mongo"
|
27
|
-
end
|
28
|
-
|
29
27
|
def heading
|
30
28
|
"Mongo: %.2fms (#{self.class.stats.queries.size} calls)" % self.class.stats.time
|
31
29
|
end
|
@@ -5,6 +5,8 @@ module Rack::Insight
|
|
5
5
|
|
6
6
|
require "rack/insight/panels/redis_panel/stats"
|
7
7
|
|
8
|
+
self.has_table = false
|
9
|
+
|
8
10
|
def self.record(redis_command_args, backtrace, &block)
|
9
11
|
return block.call unless Rack::Insight.enabled?
|
10
12
|
|
@@ -23,10 +25,6 @@ module Rack::Insight
|
|
23
25
|
Thread.current["rack-insight.redis"] ||= Stats.new
|
24
26
|
end
|
25
27
|
|
26
|
-
def name
|
27
|
-
"redis"
|
28
|
-
end
|
29
|
-
|
30
28
|
def heading
|
31
29
|
"Redis: %.2fms (#{self.class.stats.queries.size} calls)" % self.class.stats.time
|
32
30
|
end
|
@@ -52,12 +52,10 @@ module Rack::Insight
|
|
52
52
|
super
|
53
53
|
end
|
54
54
|
|
55
|
-
|
56
55
|
def call(env)
|
57
56
|
env['rack-insight.speedtracer-id'] = @uuid
|
58
57
|
|
59
58
|
status, headers, body = @app.call(env)
|
60
|
-
|
61
59
|
store(env, env['rack-insight.speedtracer-id'], env['rack-insight.speedtracer-record'])
|
62
60
|
headers['X-TraceUrl'] = '__insight__/speedtracer?id=' + env['rack-insight.speedtracer-id']
|
63
61
|
return [status, headers, body]
|
@@ -67,10 +65,6 @@ module Rack::Insight
|
|
67
65
|
{ "speedtracer" => TraceApp.new }
|
68
66
|
end
|
69
67
|
|
70
|
-
def name
|
71
|
-
"speedtracer"
|
72
|
-
end
|
73
|
-
|
74
68
|
def heading
|
75
69
|
"#{table_length} traces"
|
76
70
|
end
|
@@ -7,6 +7,11 @@ module Rack::Insight
|
|
7
7
|
|
8
8
|
FourOhFour = [404, {"Content-Type" => "text/html"}, "App tracker doesn't know that path or id"].freeze
|
9
9
|
|
10
|
+
class << self
|
11
|
+
attr_accessor :has_table
|
12
|
+
end
|
13
|
+
self.has_table = true
|
14
|
+
|
10
15
|
def initialize
|
11
16
|
table_setup("speedtracer", "uuid")
|
12
17
|
key_sql_template = "'%s'"
|
@@ -4,6 +4,8 @@ module Rack::Insight
|
|
4
4
|
require "rack/insight/panels/sphinx_panel/sphinx_extension"
|
5
5
|
require "rack/insight/panels/sphinx_panel/stats"
|
6
6
|
|
7
|
+
self.has_table = false
|
8
|
+
|
7
9
|
def self.record(*sphinx_command_args, &block)
|
8
10
|
return block.call unless Rack::Insight.enabled?
|
9
11
|
|
@@ -22,10 +24,6 @@ module Rack::Insight
|
|
22
24
|
Thread.current["rack-insight.sphinx"] ||= Stats.new
|
23
25
|
end
|
24
26
|
|
25
|
-
def name
|
26
|
-
"sphinx"
|
27
|
-
end
|
28
|
-
|
29
27
|
def heading
|
30
28
|
"Sphinx: %.2fms (#{self.class.stats.queries.size} calls)" % self.class.stats.time
|
31
29
|
end
|
@@ -7,19 +7,6 @@ module Rack::Insight
|
|
7
7
|
require "rack/insight/panels/sql_panel/panel_app"
|
8
8
|
require "rack/insight/panels/sql_panel/query"
|
9
9
|
|
10
|
-
def initialize(app)
|
11
|
-
super
|
12
|
-
probe(self) do
|
13
|
-
%w{ PostgreSQLAdapter MysqlAdapter SQLiteAdapter
|
14
|
-
Mysql2Adapter OracleEnhancedAdapter }.each do |adapter|
|
15
|
-
instrument "ActiveRecord::ConnectionAdapters::#{adapter}" do
|
16
|
-
instance_probe :execute
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
table_setup("sql_queries")
|
21
|
-
end
|
22
|
-
|
23
10
|
def self.panel_mappings
|
24
11
|
{ "sql" => PanelApp.new }
|
25
12
|
end
|
@@ -34,10 +21,6 @@ module Rack::Insight
|
|
34
21
|
end)
|
35
22
|
end
|
36
23
|
|
37
|
-
def name
|
38
|
-
"sql"
|
39
|
-
end
|
40
|
-
|
41
24
|
def heading_for_request(number)
|
42
25
|
queries = retrieve(number)
|
43
26
|
"#{queries.size} Queries (%.2fms)" % total_time(queries)
|
@@ -6,14 +6,6 @@ module Rack::Insight
|
|
6
6
|
def initialize(app)
|
7
7
|
super
|
8
8
|
|
9
|
-
probe(self) do
|
10
|
-
instrument "ActionView::Template" do
|
11
|
-
instance_probe :render
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
table_setup("templates")
|
16
|
-
|
17
9
|
@current = nil
|
18
10
|
end
|
19
11
|
|
@@ -40,17 +32,12 @@ module Rack::Insight
|
|
40
32
|
@current = @current.parent
|
41
33
|
end
|
42
34
|
|
43
|
-
def name
|
44
|
-
"templates"
|
45
|
-
end
|
46
|
-
|
47
35
|
def heading_for_request(number)
|
48
36
|
"Templates: %.2fms" % (retrieve(number).inject(0.0){|memo, rendering| memo + rendering.duration})
|
49
37
|
end
|
50
38
|
|
51
39
|
def content_for_request(number)
|
52
|
-
|
53
|
-
return result
|
40
|
+
render_template "panels/templates", :root_rendering => retrieve(number).first
|
54
41
|
end
|
55
42
|
|
56
43
|
end
|
@@ -2,14 +2,6 @@ require 'benchmark'
|
|
2
2
|
|
3
3
|
module Rack::Insight
|
4
4
|
class TimerPanel < Panel
|
5
|
-
def initialize(app)
|
6
|
-
super
|
7
|
-
table_setup("timer")
|
8
|
-
end
|
9
|
-
|
10
|
-
def name
|
11
|
-
"timer"
|
12
|
-
end
|
13
5
|
|
14
6
|
def call(env)
|
15
7
|
status, headers, body = nil
|
@@ -36,5 +28,6 @@ module Rack::Insight
|
|
36
28
|
def content_for_request(number)
|
37
29
|
render_template "panels/timer", :measurements => retrieve(number).first
|
38
30
|
end
|
31
|
+
|
39
32
|
end
|
40
33
|
end
|
data/lib/rack/insight/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
<div id="request_<%=request_id%>">
|
2
2
|
<% panels.each do |panel| %>
|
3
3
|
<% if panel.has_content? %>
|
4
|
-
<div class="panel_content" id="<%= panel.
|
4
|
+
<div class="panel_content" id="<%= panel.camelized_name %>Panel">
|
5
5
|
<div class="panel_controls">
|
6
6
|
<form action="#">
|
7
7
|
<select id="request_id_menu" name="current_request">
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-insight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2012-09-
|
15
|
+
date: 2012-09-11 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rack
|