rack-insight 0.5.14 → 0.5.15
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 +4 -3
- data/Gemfile.lock +1 -1
- data/README.md +35 -4
- data/lib/rack/insight/filtered_backtrace.rb +1 -1
- data/lib/rack/insight/panel.rb +21 -25
- data/lib/rack/insight/version.rb +1 -1
- data/lib/rack/insight/views/default_invocation.html.erb +30 -0
- data/lib/rack/insight/views/no_data.html.erb +2 -0
- metadata +3 -1
data/CHANGELOG
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
==
|
1
|
+
== 0.5.14 / 2012-09-11
|
2
2
|
|
3
3
|
* New Features
|
4
4
|
|
5
5
|
* Panel level configurations for :probes are now supported by default on all panels
|
6
6
|
* Auto-magical panel names
|
7
|
-
* Auto-magical
|
7
|
+
* Auto-magical panel probe detection and storage
|
8
|
+
* Auto-magical panel content
|
9
|
+
* Auto-magical table creation (skipped with self.has_table = false in a Panel class definition)
|
8
10
|
* Under construction, or blank, panels have more scaffolding
|
9
|
-
*
|
10
11
|
|
11
12
|
== 0.5.13 / 2012-09-10
|
12
13
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -114,15 +114,17 @@ Options:
|
|
114
114
|
Currently this is implemented in the log_panel, and configured as:
|
115
115
|
|
116
116
|
Rack::Insight::Config.configure do |config|
|
117
|
-
|
117
|
+
# The following two lines have the same result
|
118
|
+
config[:panel_configs][:log] = {:probes => {'Logger' => [:instance, :add]}}
|
119
|
+
config[:panel_configs][:log] = {:probes => ['Logger', :instance, :add]}
|
118
120
|
end
|
119
121
|
|
120
122
|
Example: If you want all of your log statements in Rails to be traced twice by Rack::Insight,
|
121
123
|
this will do that because ActiveSupport::BufferedLogger utilizes Logger under the hood:
|
122
124
|
|
123
|
-
config[:panel_configs][:log_panel] = {:
|
124
|
-
"ActiveSupport::BufferedLogger" => :add,
|
125
|
-
"Logger" => :add
|
125
|
+
config[:panel_configs][:log_panel] = {:probes => {
|
126
|
+
"ActiveSupport::BufferedLogger" => [:instance, :add],
|
127
|
+
"Logger" => [:instance, :add]
|
126
128
|
}}
|
127
129
|
|
128
130
|
|
@@ -208,6 +210,35 @@ location (i.e. Heroku), you can pass a custom file path.
|
|
208
210
|
:secret_key => "someverylongandveryhardtoguesspreferablyrandomstring",
|
209
211
|
:database_path => "tmp/my_insight_db.sqlite"
|
210
212
|
|
213
|
+
Magic Panels
|
214
|
+
------------
|
215
|
+
|
216
|
+
You can now create a fully functional new panel with a simple class definition:
|
217
|
+
|
218
|
+
module Rack::Insight
|
219
|
+
class FooBarPanel < Panel
|
220
|
+
self.is_magic = true
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
Setup the probes for the magic panel in a `before_initialize` block in your application.rb as follows:
|
225
|
+
|
226
|
+
# Assuming there is a FooBra class with instance methods: foo, bar, cheese, and ducks
|
227
|
+
Rack::Insight::Config.configure do |config|
|
228
|
+
# Not :foo_bar_panel or 'FooBarPanel'... :foo_bar
|
229
|
+
config[:panel_configs][:foo_bar] = {:probes => {'FooBra' => [:instance, :foo, :bar, :cheese, :ducks]}}
|
230
|
+
end
|
231
|
+
|
232
|
+
Custom Panels
|
233
|
+
-------------
|
234
|
+
|
235
|
+
See Magic Panels above, remove teh is_magic declaration, and add your own methods.
|
236
|
+
Look at the panels bundled with this gem for pointers. Here are some important methods to watch for:
|
237
|
+
|
238
|
+
* initialize
|
239
|
+
* after_detect
|
240
|
+
* content_for_request(number)
|
241
|
+
|
211
242
|
Authors
|
212
243
|
-------
|
213
244
|
|
@@ -10,7 +10,7 @@ module Rack::Insight
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def filtered_backtrace
|
13
|
-
@filtered_backtrace ||= @backtrace.grep(FilteredBacktrace.backtrace_regexp)
|
13
|
+
@filtered_backtrace ||= @backtrace.respond_to?(:grep) ? @backtrace.grep(FilteredBacktrace.backtrace_regexp) : []
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.backtrace_regexp
|
data/lib/rack/insight/panel.rb
CHANGED
@@ -132,7 +132,7 @@ module Rack::Insight
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
else
|
135
|
-
raise "Expected Rack::Insight::Config.config[:panel_configs][#{
|
135
|
+
raise "Expected Rack::Insight::Config.config[:panel_configs][#{panel_name}][: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
136
|
end
|
137
137
|
end
|
138
138
|
|
@@ -240,28 +240,14 @@ module Rack::Insight
|
|
240
240
|
logger.info("#{self.class} is being used without a table") if verbose(:med)
|
241
241
|
content
|
242
242
|
elsif self.is_probed?
|
243
|
-
html = "<h3>#{self.camelized_name}</h3>"
|
244
243
|
invocations = retrieve(number)
|
245
244
|
if invocations.length > 0 && invocations.first.is_a?(Rack::Insight::Panel::DefaultInvocation)
|
246
|
-
|
247
|
-
|
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>'
|
245
|
+
logger.info("Rack::Insight is using magic content for #{self.class}, which is probed")# if verbose(:med)
|
246
|
+
render_template 'default_invocation', :invocations => invocations, :name => self.camelized_name
|
261
247
|
else
|
262
|
-
|
248
|
+
logger.info("Rack::Insight has no data for magic content for #{self.class}, which is probed")# if verbose(:med)
|
249
|
+
render_template 'no_data', :name => self.camelized_name
|
263
250
|
end
|
264
|
-
html
|
265
251
|
else
|
266
252
|
content
|
267
253
|
end
|
@@ -284,7 +270,7 @@ module Rack::Insight
|
|
284
270
|
def after_detect(method_call, timing, args, result)
|
285
271
|
#puts "Default After Detect for #{self.underscored_name}: 1. #{self.is_magic?} && 2. #{self.has_table?} && 3. #{self.is_probed?}"
|
286
272
|
if self.is_magic? && self.has_table? && self.is_probed?
|
287
|
-
store(@env, DefaultInvocation.new(method_call.to_s, timing
|
273
|
+
store(@env, DefaultInvocation.new(method_call.method.to_s, timing, args, result, method_call.backtrace[2..-1]))
|
288
274
|
end
|
289
275
|
end
|
290
276
|
|
@@ -297,14 +283,24 @@ module Rack::Insight
|
|
297
283
|
def render(template)
|
298
284
|
end
|
299
285
|
|
300
|
-
# For Magic Panels
|
301
|
-
class DefaultInvocation < Struct.new :method, :time, :
|
286
|
+
# For Magic Panels
|
287
|
+
class DefaultInvocation < Struct.new :method, :time, :arguments, :result, :backtrace
|
288
|
+
attr_accessor :method, :time, :arguments, :result, :backtrace
|
289
|
+
|
290
|
+
include Rack::Insight::FilteredBacktrace
|
291
|
+
|
302
292
|
def initialize(*args)
|
303
|
-
@
|
293
|
+
@method = args[0]
|
294
|
+
@time = [args[1].duration, args[1].delta_t]
|
295
|
+
@arguments = args[2]
|
296
|
+
@result = args[3]
|
297
|
+
@backtrace = args[4]
|
304
298
|
end
|
305
|
-
|
306
|
-
|
299
|
+
|
300
|
+
def human_time
|
301
|
+
"%.2fms" % (self.time * 1_000)
|
307
302
|
end
|
303
|
+
|
308
304
|
end
|
309
305
|
|
310
306
|
end
|
data/lib/rack/insight/version.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
<h3><%= name %></h3>
|
2
|
+
<table>
|
3
|
+
<thead>
|
4
|
+
<tr>
|
5
|
+
<%- members = invocations.last.members # is a struct, so we have members, not keys %>
|
6
|
+
<%- members.each do |member| %>
|
7
|
+
<td><%= member %></td>
|
8
|
+
<%- end %>
|
9
|
+
</tr>
|
10
|
+
</thead>
|
11
|
+
<tbody>
|
12
|
+
<%- invocations.each do |invocation| %>
|
13
|
+
<tr>
|
14
|
+
<%- members.each do |member| %>
|
15
|
+
<td>
|
16
|
+
<%- if member == :backtrace %>
|
17
|
+
<%- invocation.filtered_backtrace.each do |line| %>
|
18
|
+
<%= line %><br/>
|
19
|
+
<%- end %>
|
20
|
+
<%- elsif member == :time %>
|
21
|
+
<%= invocation.human_time %>
|
22
|
+
<%- else %>
|
23
|
+
<%= invocation.send(member).inspect %>
|
24
|
+
<%- end %>
|
25
|
+
</td>
|
26
|
+
<%- end %>
|
27
|
+
</tr>
|
28
|
+
<%- end %>
|
29
|
+
</tbody>
|
30
|
+
</table>
|
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.15
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -280,9 +280,11 @@ files:
|
|
280
280
|
- lib/rack/insight/rspec_matchers.rb
|
281
281
|
- lib/rack/insight/toolbar.rb
|
282
282
|
- lib/rack/insight/version.rb
|
283
|
+
- lib/rack/insight/views/default_invocation.html.erb
|
283
284
|
- lib/rack/insight/views/enable-button.html.erb
|
284
285
|
- lib/rack/insight/views/error.html.erb
|
285
286
|
- lib/rack/insight/views/headers_fragment.html.erb
|
287
|
+
- lib/rack/insight/views/no_data.html.erb
|
286
288
|
- lib/rack/insight/views/panels/active_record.html.erb
|
287
289
|
- lib/rack/insight/views/panels/active_resource.html.erb
|
288
290
|
- lib/rack/insight/views/panels/cache.html.erb
|