rack-insight 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. data/.gitignore +13 -0
  2. data/.rspec +1 -0
  3. data/.simplecov +4 -0
  4. data/.travis.yml +8 -0
  5. data/CHANGELOG +58 -0
  6. data/Gemfile +3 -0
  7. data/Gemfile.lock +82 -0
  8. data/LICENSE +24 -0
  9. data/README.md +189 -0
  10. data/Rakefile +27 -0
  11. data/TODO +7 -0
  12. data/lib/rack-insight.rb +1 -0
  13. data/lib/rack/insight.rb +19 -0
  14. data/lib/rack/insight/app.rb +198 -0
  15. data/lib/rack/insight/config.rb +30 -0
  16. data/lib/rack/insight/database.rb +193 -0
  17. data/lib/rack/insight/enable-button.rb +43 -0
  18. data/lib/rack/insight/filtered_backtrace.rb +45 -0
  19. data/lib/rack/insight/instrumentation.rb +9 -0
  20. data/lib/rack/insight/instrumentation/backstage.rb +10 -0
  21. data/lib/rack/insight/instrumentation/client.rb +20 -0
  22. data/lib/rack/insight/instrumentation/instrument.rb +109 -0
  23. data/lib/rack/insight/instrumentation/package-definition.rb +58 -0
  24. data/lib/rack/insight/instrumentation/probe-definition.rb +20 -0
  25. data/lib/rack/insight/instrumentation/probe.rb +196 -0
  26. data/lib/rack/insight/instrumentation/setup.rb +32 -0
  27. data/lib/rack/insight/logger.rb +53 -0
  28. data/lib/rack/insight/options.rb +116 -0
  29. data/lib/rack/insight/panel.rb +135 -0
  30. data/lib/rack/insight/panel_app.rb +31 -0
  31. data/lib/rack/insight/panels-content.rb +22 -0
  32. data/lib/rack/insight/panels-header.rb +18 -0
  33. data/lib/rack/insight/panels/active_record_panel.rb +46 -0
  34. data/lib/rack/insight/panels/active_resource_panel.rb +48 -0
  35. data/lib/rack/insight/panels/active_resource_panel/query.rb +27 -0
  36. data/lib/rack/insight/panels/cache_panel.rb +68 -0
  37. data/lib/rack/insight/panels/cache_panel/panel_app.rb +46 -0
  38. data/lib/rack/insight/panels/cache_panel/stats.rb +90 -0
  39. data/lib/rack/insight/panels/log_panel.rb +53 -0
  40. data/lib/rack/insight/panels/memory_panel.rb +36 -0
  41. data/lib/rack/insight/panels/mongo_panel.rb +41 -0
  42. data/lib/rack/insight/panels/mongo_panel/mongo_extension.rb +24 -0
  43. data/lib/rack/insight/panels/mongo_panel/stats.rb +46 -0
  44. data/lib/rack/insight/panels/rails_info_panel.rb +19 -0
  45. data/lib/rack/insight/panels/redis_panel.rb +42 -0
  46. data/lib/rack/insight/panels/redis_panel/redis_extension.rb +23 -0
  47. data/lib/rack/insight/panels/redis_panel/stats.rb +50 -0
  48. data/lib/rack/insight/panels/request_variables_panel.rb +70 -0
  49. data/lib/rack/insight/panels/speedtracer_panel.rb +89 -0
  50. data/lib/rack/insight/panels/speedtracer_panel/profiling.rb +29 -0
  51. data/lib/rack/insight/panels/speedtracer_panel/trace-app.rb +52 -0
  52. data/lib/rack/insight/panels/speedtracer_panel/tracer.rb +213 -0
  53. data/lib/rack/insight/panels/sphinx_panel.rb +41 -0
  54. data/lib/rack/insight/panels/sphinx_panel/stats.rb +94 -0
  55. data/lib/rack/insight/panels/sql_panel.rb +53 -0
  56. data/lib/rack/insight/panels/sql_panel/panel_app.rb +37 -0
  57. data/lib/rack/insight/panels/sql_panel/query.rb +94 -0
  58. data/lib/rack/insight/panels/templates_panel.rb +58 -0
  59. data/lib/rack/insight/panels/templates_panel/rendering.rb +81 -0
  60. data/lib/rack/insight/panels/timer_panel.rb +40 -0
  61. data/lib/rack/insight/params_signature.rb +61 -0
  62. data/lib/rack/insight/path-filter.rb +23 -0
  63. data/lib/rack/insight/public/__insight__/bookmarklet.html +10 -0
  64. data/lib/rack/insight/public/__insight__/bookmarklet.js +223 -0
  65. data/lib/rack/insight/public/__insight__/insight.css +235 -0
  66. data/lib/rack/insight/public/__insight__/insight.js +127 -0
  67. data/lib/rack/insight/public/__insight__/jquery-1.3.2.js +4376 -0
  68. data/lib/rack/insight/public/__insight__/jquery.tablesorter.min.js +1 -0
  69. data/lib/rack/insight/public/__insight__/spinner.gif +0 -0
  70. data/lib/rack/insight/rack_static_bug_avoider.rb +16 -0
  71. data/lib/rack/insight/redirect_interceptor.rb +25 -0
  72. data/lib/rack/insight/render.rb +72 -0
  73. data/lib/rack/insight/request-recorder.rb +22 -0
  74. data/lib/rack/insight/rspec_matchers.rb +33 -0
  75. data/lib/rack/insight/toolbar.rb +69 -0
  76. data/lib/rack/insight/version.rb +7 -0
  77. data/lib/rack/insight/views/enable-button.html.erb +21 -0
  78. data/lib/rack/insight/views/error.html.erb +17 -0
  79. data/lib/rack/insight/views/headers_fragment.html.erb +20 -0
  80. data/lib/rack/insight/views/panels/active_record.html.erb +17 -0
  81. data/lib/rack/insight/views/panels/active_resource.html.erb +47 -0
  82. data/lib/rack/insight/views/panels/cache.html.erb +93 -0
  83. data/lib/rack/insight/views/panels/execute_sql.html.erb +32 -0
  84. data/lib/rack/insight/views/panels/explain_sql.html.erb +32 -0
  85. data/lib/rack/insight/views/panels/log.html.erb +21 -0
  86. data/lib/rack/insight/views/panels/mongo.html.erb +32 -0
  87. data/lib/rack/insight/views/panels/profile_sql.html.erb +32 -0
  88. data/lib/rack/insight/views/panels/rails_info.html.erb +19 -0
  89. data/lib/rack/insight/views/panels/redis.html.erb +46 -0
  90. data/lib/rack/insight/views/panels/request_variables.html.erb +25 -0
  91. data/lib/rack/insight/views/panels/speedtracer/serverevent.html.erb +10 -0
  92. data/lib/rack/insight/views/panels/speedtracer/servertrace.html.erb +12 -0
  93. data/lib/rack/insight/views/panels/speedtracer/traces.html.erb +18 -0
  94. data/lib/rack/insight/views/panels/sphinx.html.erb +32 -0
  95. data/lib/rack/insight/views/panels/sql.html.erb +43 -0
  96. data/lib/rack/insight/views/panels/templates.html.erb +6 -0
  97. data/lib/rack/insight/views/panels/timer.html.erb +19 -0
  98. data/lib/rack/insight/views/panels/view_cache.html.erb +19 -0
  99. data/lib/rack/insight/views/redirect.html.erb +16 -0
  100. data/lib/rack/insight/views/request_fragment.html.erb +25 -0
  101. data/lib/rack/insight/views/toolbar.html.erb +29 -0
  102. data/rack-insight.gemspec +40 -0
  103. data/spec/custom_matchers.rb +0 -0
  104. data/spec/fixtures/config.ru +8 -0
  105. data/spec/fixtures/dummy_panel.rb +2 -0
  106. data/spec/fixtures/sample_app.rb +72 -0
  107. data/spec/fixtures/star_trek_panel.rb +1 -0
  108. data/spec/insight_spec.rb +163 -0
  109. data/spec/instrumentation_spec.rb +188 -0
  110. data/spec/rack/insight/config_spec.rb +20 -0
  111. data/spec/rack/insight/panels/active_record_panel_spec.rb +43 -0
  112. data/spec/rack/insight/panels/active_resource_panel_spec.rb +40 -0
  113. data/spec/rack/insight/panels/cache_panel_spec.rb +178 -0
  114. data/spec/rack/insight/panels/log_panel_spec.rb +44 -0
  115. data/spec/rack/insight/panels/memory_panel_spec.rb +21 -0
  116. data/spec/rack/insight/panels/mongo_panel_spec_pending.rb +52 -0
  117. data/spec/rack/insight/panels/rails_info_panel_spec.rb +29 -0
  118. data/spec/rack/insight/panels/redis_panel_spec.rb +67 -0
  119. data/spec/rack/insight/panels/speedtracer_panel_spec.rb +86 -0
  120. data/spec/rack/insight/panels/sql_panel_spec.rb +146 -0
  121. data/spec/rack/insight/panels/templates_panel_spec.rb +86 -0
  122. data/spec/rack/insight/panels/timer_panel_spec.rb +38 -0
  123. data/spec/rcov.opts +1 -0
  124. data/spec/spec.opts +1 -0
  125. data/spec/spec_helper.rb +111 -0
  126. metadata +380 -0
@@ -0,0 +1,32 @@
1
+ <a class="back" href="">&laquo;&nbsp;Back</a>
2
+
3
+ <h3>SQL Results</h3>
4
+
5
+ <dl>
6
+ <dt>Executed SQL</dt>
7
+ <dd><pre><%=h query.sql %></pre></dd>
8
+
9
+ <dt>Time</dt>
10
+ <dd><%=h "%.2f" % (query.time * 1_000) %>ms</dd>
11
+ </dl>
12
+
13
+ <table class="sortable">
14
+ <thead>
15
+ <tr>
16
+ <% query.column_names.each do |field| %>
17
+ <th><%= field.upcase %></th>
18
+ <% end %>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <% i = 1 %>
23
+ <% query.rows.each do |row| %>
24
+ <tr class="<%= i % 2 == 0 ? "even" : "odd" %>">
25
+ <% row.each do |value| %>
26
+ <td><%= value %></td>
27
+ <% end %>
28
+ </tr>
29
+ <% i += 1 %>
30
+ <% end %>
31
+ </tbody>
32
+ </table>
@@ -0,0 +1,32 @@
1
+ <a class="back" href="">&laquo;&nbsp;Back</a>
2
+
3
+ <h3>SQL Explained</h3>
4
+
5
+ <dl>
6
+ <dt>Executed SQL</dt>
7
+ <dd><pre><%=h query.sql %></pre></dd>
8
+
9
+ <dt>Time</dt>
10
+ <dd><%=h "%.2f" % (query.time * 1_000) %>ms</dd>
11
+ </dl>
12
+
13
+ <table class="sortable">
14
+ <thead>
15
+ <tr>
16
+ <% query.column_names.each do |field| %>
17
+ <th><%= field.upcase %></th>
18
+ <% end %>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <% i = 1 %>
23
+ <% query.rows.each do |row| %>
24
+ <tr class="<%= i % 2 == 0 ? "even" : "odd" %>">
25
+ <% row.each do |value| %>
26
+ <td><%= value %></td>
27
+ <% end %>
28
+ </tr>
29
+ <% i += 1 %>
30
+ <% end %>
31
+ </tbody>
32
+ </table>
@@ -0,0 +1,21 @@
1
+ <h3>Log Messages</h3>
2
+ <table>
3
+ <thead>
4
+ <tr>
5
+ <th>Level</th>
6
+ <th>Time</th>
7
+ <th>Message</th>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <% i = 1 %>
12
+ <% logs.each do |entry| %>
13
+ <tr class="<%= i % 2 == 0 ? "even" : "odd" %>">
14
+ <td><%= entry.level %></td>
15
+ <td><%= entry.time %>ms</td>
16
+ <td><%= entry.cleaned_message %></td>
17
+ </tr>
18
+ <% i += 1 %>
19
+ <% end %>
20
+ </tbody>
21
+ </table>
@@ -0,0 +1,32 @@
1
+ <h3>Mongo Usage</h3>
2
+ <table id="mongo_usage">
3
+ <tr>
4
+ <th>Total Calls</th>
5
+ <td><%= stats.calls %></td>
6
+
7
+ <th>Total Time</th>
8
+ <td><%= stats.display_time %></td>
9
+ </tr>
10
+ </table>
11
+
12
+ <% if stats.queries.any? %>
13
+ <h3>Breakdown</h3>
14
+ <table id="mongo_breakdown">
15
+ <thead>
16
+ <tr>
17
+ <th>Time&nbsp;(ms)</th>
18
+ <th>Command</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <% i = 1 %>
23
+ <% stats.queries.each do |query| %>
24
+ <tr class="<%= i % 2 == 0 ? "even" : "odd" %>">
25
+ <td><%= query.display_time %></td>
26
+ <td><%= query.command %></td>
27
+ </tr>
28
+ <% i += 1 %>
29
+ <% end %>
30
+ </tbody>
31
+ </table>
32
+ <% end %>
@@ -0,0 +1,32 @@
1
+ <a class="back" href="">&laquo;&nbsp;Back</a>
2
+
3
+ <h3>SQL Profiled</h3>
4
+
5
+ <dl>
6
+ <dt>Executed SQL</dt>
7
+ <dd><pre><%=h query %></pre></dd>
8
+
9
+ <dt>Time</dt>
10
+ <dd><%=h "%.2f" % (time * 1_000) %>ms</dd>
11
+ </dl>
12
+
13
+ <table class="sortable">
14
+ <thead>
15
+ <tr>
16
+ <% result.fetch_fields.each do |field| %>
17
+ <th><%= field.name.upcase %></th>
18
+ <% end %>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <% i = 1 %>
23
+ <% result.each do |row| %>
24
+ <tr class="<%= i % 2 == 0 ? "even" : "odd" %>">
25
+ <% row.each do |value| %>
26
+ <td><%= value %></td>
27
+ <% end %>
28
+ </tr>
29
+ <% i += 1 %>
30
+ <% end %>
31
+ </tbody>
32
+ </table>
@@ -0,0 +1,19 @@
1
+ <h3>Rails Environment</h3>
2
+ <table>
3
+ <thead>
4
+ <tr>
5
+ <th>Variable</th>
6
+ <th>Value</th>
7
+ </tr>
8
+ </thead>
9
+ <tbody>
10
+ <% i = 1 %>
11
+ <% Rails::Info.properties.each do |key, val| %>
12
+ <tr class="<%= i % 2 == 0 ? "even" : "odd" %>">
13
+ <td><%=h key %></td>
14
+ <td class="code"><div><%=h val %></div></td>
15
+ </tr>
16
+ <% i += 1 %>
17
+ <% end %>
18
+ </tbody>
19
+ </table>
@@ -0,0 +1,46 @@
1
+ <h3>Redis Usage</h3>
2
+ <table id="redis_usage">
3
+ <tr>
4
+ <th>Total Calls</th>
5
+ <td><%= stats.calls %></td>
6
+
7
+ <th>Total Time</th>
8
+ <td><%= stats.display_time %></td>
9
+ </tr>
10
+ </table>
11
+
12
+ <% if stats.queries.any? %>
13
+ <h3>Breakdown</h3>
14
+ <table id="redis_breakdown">
15
+ <thead>
16
+ <tr>
17
+ <th>Time&nbsp;(ms)</th>
18
+ <th>Command</th>
19
+ <th class="backtrace"></th>
20
+ </tr>
21
+ </thead>
22
+ <tbody>
23
+ <% i = 1 %>
24
+ <% stats.queries.each do |query| %>
25
+ <tr class="<%= i % 2 == 0 ? "even" : "odd" %>">
26
+ <td><%= query.display_time %></td>
27
+ <td><%= query.command %></td>
28
+ <td><%= "<a href='#' class='reveal_backtrace'>Show Backtrace</a>" if query.has_backtrace? %></td>
29
+ </tr>
30
+ <% if query.has_backtrace? %>
31
+ <tr style="display:none">
32
+ <td></td>
33
+ <td colspan="2">
34
+ <ul>
35
+ <% query.filtered_backtrace.each do |line| %>
36
+ <li><%=h line %></li>
37
+ <% end %>
38
+ </ul>
39
+ </td>
40
+ </tr>
41
+ <% end %>
42
+ <% i += 1 %>
43
+ <% end %>
44
+ </tbody>
45
+ </table>
46
+ <% end %>
@@ -0,0 +1,25 @@
1
+ <% ["GET", "POST", "Session", "Cookies", "SERVER VARIABLES", "Rack ENV"].each do |header|
2
+ next unless sections.has_key?(header)
3
+ %>
4
+ <h3><%=header%></h3>
5
+ <table id="request_variables">
6
+ <thead>
7
+ <tr>
8
+ <th>Variable</th>
9
+ <th>Value</th>
10
+ </tr>
11
+ </thead>
12
+ <tbody>
13
+ <% i = 1 %>
14
+ <% sections[header].each do |key, val| %>
15
+ <tr class="<%= i % 2 == 0 ? "even" : "odd" %>">
16
+ <td><%=h key %></td>
17
+ <td class="code"><div>
18
+ <%=h val%>
19
+ </div></td>
20
+ </tr>
21
+ <% i += 1 %>
22
+ <% end %>
23
+ </tbody>
24
+ </table>
25
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <div class="traceblock">
2
+ <%=operation['label']%> - <%=range['duration']%>ms (self: <%=self_time%>ms)
3
+ <% unless children.empty? %>
4
+ <ul>
5
+ <% children.each do |child|%>
6
+ <li><%=child.to_html%></li>
7
+ <%end%>
8
+ </ul>
9
+ <% end %>
10
+ </div>
@@ -0,0 +1,12 @@
1
+ <a href='<%=url%>'>Raw JSON</a>
2
+ <dl>
3
+ <dt>Name</dt><dd><%=frameStack['label']%></dd>
4
+ <dt>Began</dt><dd><%=frameStack['range']['start']%></dd>
5
+ <dt>Duration</dt><dd><%=frameStack['range']['duration']%></dd>
6
+ <dt>Children</dt>
7
+ <dd><ul>
8
+ <% frameStack['children'].each do |child| %>
9
+ <li><%= child.to_html %></li>
10
+ <%end%>
11
+ </ul></dd>
12
+ </dl>
@@ -0,0 +1,18 @@
1
+ <h3>Trace</h3>
2
+ <h4>Process: <%= Process.pid %> (<%= Process.ppid %>)</h4>
3
+ <% unless advice.empty? %>
4
+ <p>Warning:</p>
5
+ <ul>
6
+ <% advice.each do |item| %>
7
+ <li><%= item %></li>
8
+ <% end %>
9
+ </ul>
10
+ <% end %>
11
+ <dl>
12
+ <% if trace.nil? %>
13
+ <dt>Problem</dt><dd>Trace is nil</dd>
14
+ <% else %>
15
+ <dt><%= trace.uuid %> - <%= trace.start.strftime("%H:%M:%S") %></dt>
16
+ <dd><%= trace.to_html %></dd>
17
+ <% end %>
18
+ </dl>
@@ -0,0 +1,32 @@
1
+ <h3>Sphinx Usage</h3>
2
+ <table id="Sphinx_usage">
3
+ <tr>
4
+ <th>Total Calls</th>
5
+ <td><%= stats.calls %></td>
6
+
7
+ <th>Total Time</th>
8
+ <td><%= stats.display_time %></td>
9
+ </tr>
10
+ </table>
11
+
12
+ <% if stats.queries.any? %>
13
+ <h3>Breakdown</h3>
14
+ <table id="Sphinx_breakdown">
15
+ <thead>
16
+ <tr>
17
+ <th>Time&nbsp;(ms)</th>
18
+ <th>Command</th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <% i = 1 %>
23
+ <% stats.queries.each do |query| %>
24
+ <tr class="<%= i % 2 == 0 ? "even" : "odd" %>">
25
+ <td><%= query.display_time %></td>
26
+ <td><%= query.command %></td>
27
+ </tr>
28
+ <% i += 1 %>
29
+ <% end %>
30
+ </tbody>
31
+ </table>
32
+ <% end %>
@@ -0,0 +1,43 @@
1
+ <h3>SQL 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"></th>
8
+ <th class="actions"></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.sql %></td>
17
+ <td>
18
+ <% if query.has_backtrace? %>
19
+ <a href="#" class="reveal_backtrace">Show Backtrace</a>
20
+ <% end %>
21
+ </td>
22
+ <td>
23
+ <% if query.inspectable? %>
24
+ <a href="/__insight__/sql/execute?<%= signed_params("query" => query.sql, "time" => query.time) %>" class="remote_call">SELECT</a> |
25
+ <a href="/__insight__/sql/explain?<%= signed_params("query" => query.sql, "time" => query.time) %>" class="remote_call">EXPLAIN</a> |
26
+ <a href="/__insight__/sql/profile?<%= signed_params("query" => query.sql, "time" => query.time) %>" class="remote_call">Profile</a>
27
+ <% end %>
28
+ </td>
29
+ </tr>
30
+ <tr style="display:none">
31
+ <td></td>
32
+ <td colspan="3">
33
+ <ul>
34
+ <% query.filtered_backtrace.each do |line| %>
35
+ <li><%=h line %></li>
36
+ <% end %>
37
+ </ul>
38
+ </td>
39
+ </tr>
40
+ <% i += 1 %>
41
+ <% end %>
42
+ </tbody>
43
+ </table>
@@ -0,0 +1,6 @@
1
+ <h3>Templates</h3>
2
+ <ul>
3
+ <% root_rendering.children.each do |child| %>
4
+ <%= child.html %>
5
+ <% end %>
6
+ </ul>
@@ -0,0 +1,19 @@
1
+ <h3>Resource Usage</h3>
2
+ <table class="sortable">
3
+ <thead>
4
+ <tr>
5
+ <th>Key</th>
6
+ <th>Value</th>
7
+ </tr>
8
+ </thead>
9
+ <tbody>
10
+ <% i = 1 %>
11
+ <% measurements.each do |key, val| %>
12
+ <tr class="<%= i % 2 == 0 ? "even" : "odd" %>">
13
+ <td><%=h key %></td>
14
+ <td><%=h val %></td>
15
+ </tr>
16
+ <% i += 1 %>
17
+ <% end %>
18
+ </tbody>
19
+ </table>
@@ -0,0 +1,19 @@
1
+ <a class="back" href="">&laquo;&nbsp;Back</a>
2
+
3
+ <h3>Cache Read</h3>
4
+
5
+ <dl>
6
+ <dt>Key</dt>
7
+ <dd><pre><%=h key %></pre></dd>
8
+
9
+ <dt>Time</dt>
10
+ <dd><%=h "%.2f" % (0.0 * 1_000) %>ms</dd>
11
+ </dl>
12
+
13
+ <p>
14
+ <% if value.is_a?(String )%>
15
+ <%=h value %>
16
+ <% else %>
17
+ <%=h value.inspect %>
18
+ <% end %>
19
+ </p>
@@ -0,0 +1,16 @@
1
+ <html>
2
+ <head>
3
+ </head>
4
+ <body>
5
+ <h1>Redirect</h1>
6
+
7
+ <p>Location: <a href="<%= redirect_to %>"><%= redirect_to %></a></p>
8
+
9
+ <p class="notice">
10
+ Rack::Insight has intercepted a redirect to the above URL for debug viewing
11
+ purposes. You can click the above link to continue with the redirect as
12
+ normal. If you'd like to disable this feature, set the Rack::Insight
13
+ <code>internal_redirects</code> option to <code>false</code>.
14
+ </p>
15
+ </body>
16
+ </html>