logical-insight 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,48 @@
1
+ require "digest"
2
+
3
+ module Insight
4
+ class ActiveResourcePanel < Panel
5
+ require 'insight/panels/active_resource_panel/query'
6
+ #require "insight/panels/sql_panel/panel_app"
7
+ #require "insight/panels/sql_panel/query"
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
+ def after_detect(method_call, timing, arguments, results)
20
+ body = "<no body>"
21
+ if results.respond_to? :body
22
+ body = results.body
23
+ end
24
+ store(@env, RequestResult.new(arguments[0], arguments[1..-1], timing.duration, method_call.backtrace[0..5], body))
25
+ end
26
+
27
+ def total_time(queries)
28
+ (queries.inject(0) do |memo, query|
29
+ memo + query.time
30
+ end)
31
+ end
32
+
33
+ def name
34
+ "active_resource"
35
+ end
36
+
37
+ def heading_for_request(number)
38
+ queries = retrieve(number)
39
+ "ARes: #{queries.size} Queries (%.2fms)" % total_time(queries)
40
+ end
41
+
42
+ def content_for_request(number)
43
+ queries = retrieve(number)
44
+ logger.debug{ "ARes: #{queries.inspect}" }
45
+ render_template "panels/active_resource", :queries => queries
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,27 @@
1
+ module Insight
2
+ class ActiveResourcePanel
3
+ class RequestResult
4
+ include Insight::FilteredBacktrace
5
+
6
+ attr_reader :path, :args, :result, :time
7
+ alias results result
8
+
9
+ def initialize(path, args, time, backtrace = [], result=nil)
10
+ @path = path
11
+ @args = args
12
+ @time = time
13
+ @backtrace = backtrace
14
+ @result = result
15
+ end
16
+
17
+ def human_time
18
+ "%.2fms" % (@time)
19
+ end
20
+
21
+ def valid_hash?(secret_key, possible_hash)
22
+ hash = Digest::SHA1.hexdigest [secret_key, @sql].join(":")
23
+ possible_hash == hash
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,47 @@
1
+ <h3>ActiveResource HTTP Queries</h3>
2
+ <table class="sortable">
3
+ <thead>
4
+ <tr>
5
+ <th class="time">Time&nbsp;(ms)</th>
6
+ <th class="query">Query</th>
7
+ <th class="backtrace">Backtrace</th>
8
+ <th class="result">Result</th>
9
+ </tr>
10
+ </thead>
11
+ <tbody>
12
+ <% i = 1 %>
13
+ <% queries.each do |query| %>
14
+ <tr class="<%= i % 2 == 0 ? "even" : "odd" %>">
15
+ <td><%= query.human_time %></td>
16
+ <td class="syntax"><%= query.path %><%= query.args.inspect %></td>
17
+ <td>
18
+ <% if query.has_backtrace? %>
19
+ <a href="#" class="reveal_backtrace">Show Backtrace</a>
20
+ <% end %>
21
+ </td>
22
+ <td>
23
+ <a href="#" class="reveal_response">Show Response Body</a>
24
+ </td>
25
+ </tr>
26
+ <tr style="display:none">
27
+ <td></td>
28
+ <td colspan="3">
29
+ <ul>
30
+ <% query.filtered_backtrace.each do |line| %>
31
+ <li><%=h line %></li>
32
+ <% end %>
33
+ </ul>
34
+ </td>
35
+ </tr>
36
+ <tr id="response" style="display:none">
37
+ <td></td>
38
+ <td colspan="3">
39
+ <p><%= query.results %></p>
40
+ <!-- <%= query.inspect %> -->
41
+ <!-- <%= query.results.inspect %> -->
42
+ </td>
43
+ </tr>
44
+ <% i += 1 %>
45
+ <% end %>
46
+ </tbody>
47
+ </table>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logical-insight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -15,7 +15,7 @@ date: 2012-05-17 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: corundum
18
- requirement: &81106850 !ruby/object:Gem::Requirement
18
+ requirement: &84285480 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: 0.0.13
24
24
  type: :development
25
25
  prerelease: false
26
- version_requirements: *81106850
26
+ version_requirements: *84285480
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: redcarpet
29
- requirement: &81119770 !ruby/object:Gem::Requirement
29
+ requirement: &84285080 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
- version_requirements: *81119770
37
+ version_requirements: *84285080
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: uuid
40
- requirement: &81118520 !ruby/object:Gem::Requirement
40
+ requirement: &84284500 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
@@ -49,10 +49,10 @@ dependencies:
49
49
  - 1
50
50
  type: :runtime
51
51
  prerelease: false
52
- version_requirements: *81118520
52
+ version_requirements: *84284500
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: sqlite3
55
- requirement: &81116710 !ruby/object:Gem::Requirement
55
+ requirement: &84283960 !ruby/object:Gem::Requirement
56
56
  none: false
57
57
  requirements:
58
58
  - - ~>
@@ -64,7 +64,7 @@ dependencies:
64
64
  - 3
65
65
  type: :runtime
66
66
  prerelease: false
67
- version_requirements: *81116710
67
+ version_requirements: *84283960
68
68
  description: ! "Debugging toolbar for Rack applications implemented as\n middleware.
69
69
  \ Rails 3 compatible version maintained by Logical Reality\n Design. "
70
70
  email:
@@ -101,6 +101,7 @@ files:
101
101
  - lib/insight/views/panels/request_variables.html.erb
102
102
  - lib/insight/views/panels/profile_sql.html.erb
103
103
  - lib/insight/views/panels/redis.html.erb
104
+ - lib/insight/views/panels/active_resource.html.erb
104
105
  - lib/insight/views/toolbar.html.erb
105
106
  - lib/insight/views/error.html.erb
106
107
  - lib/insight/options.rb
@@ -134,6 +135,8 @@ files:
134
135
  - lib/insight/panels/speedtracer_panel.rb
135
136
  - lib/insight/panels/templates_panel/rendering.rb
136
137
  - lib/insight/panels/memory_panel.rb
138
+ - lib/insight/panels/active_resource_panel.rb
139
+ - lib/insight/panels/active_resource_panel/query.rb
137
140
  - lib/insight/request-recorder.rb
138
141
  - lib/insight/public/__insight__/bookmarklet.html
139
142
  - lib/insight/public/__insight__/bookmarklet.js
@@ -191,7 +194,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
191
194
  version: '0'
192
195
  segments:
193
196
  - 0
194
- hash: -526620845
197
+ hash: 675690895
195
198
  required_rubygems_version: !ruby/object:Gem::Requirement
196
199
  none: false
197
200
  requirements: