tuttle 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/README.md +61 -4
  4. data/Rakefile +1 -16
  5. data/app/controllers/tuttle/active_job_controller.rb +51 -0
  6. data/app/controllers/tuttle/active_model_serializers_controller.rb +3 -8
  7. data/app/controllers/tuttle/application_controller.rb +3 -0
  8. data/app/controllers/tuttle/cancancan_controller.rb +8 -15
  9. data/app/controllers/tuttle/devise_controller.rb +1 -2
  10. data/app/controllers/tuttle/gems_controller.rb +4 -4
  11. data/app/controllers/tuttle/home_controller.rb +0 -1
  12. data/app/controllers/tuttle/paperclip_controller.rb +1 -2
  13. data/app/controllers/tuttle/rack_mini_profiler_controller.rb +15 -0
  14. data/app/controllers/tuttle/rails_controller.rb +45 -7
  15. data/app/controllers/tuttle/request_controller.rb +0 -4
  16. data/app/controllers/tuttle/ruby_controller.rb +6 -2
  17. data/app/helpers/tuttle/application_helper.rb +13 -8
  18. data/app/models/tuttle/configuration_registry.rb +25 -0
  19. data/app/models/tuttle/version_detector.rb +9 -0
  20. data/app/views/layouts/tuttle/application.html.erb +29 -20
  21. data/app/views/tuttle/active_job/index.html.erb +48 -0
  22. data/app/views/tuttle/active_model_serializers/index.html.erb +2 -0
  23. data/app/views/tuttle/gems/get_process_mem.html.erb +13 -13
  24. data/app/views/tuttle/gems/http_clients.html.erb +9 -10
  25. data/app/views/tuttle/gems/json.html.erb +3 -3
  26. data/app/views/tuttle/gems/other.html.erb +41 -11
  27. data/app/views/tuttle/home/index.html.erb +27 -23
  28. data/app/views/tuttle/{performance_tuning → rack_mini_profiler}/index.html.erb +6 -6
  29. data/app/views/tuttle/rails/_cache_dalli_store.html.erb +65 -0
  30. data/app/views/tuttle/rails/_cache_memory_store.html.erb +43 -0
  31. data/app/views/tuttle/rails/_cache_monitor.html.erb +63 -0
  32. data/app/views/tuttle/rails/assets.html.erb +181 -28
  33. data/app/views/tuttle/rails/cache.html.erb +92 -102
  34. data/app/views/tuttle/rails/database.html.erb +2 -2
  35. data/app/views/tuttle/rails/index.html.erb +20 -21
  36. data/app/views/tuttle/rails/routes.html.erb +88 -36
  37. data/app/views/tuttle/rails/schema_cache.html.erb +2 -1
  38. data/app/views/tuttle/ruby/index.html.erb +24 -20
  39. data/config/rails_config_base.yml +80 -0
  40. data/config/rails_config_v4.x.yml +14 -0
  41. data/config/rails_config_v5.x.yml +12 -0
  42. data/config/routes.rb +7 -1
  43. data/lib/tuttle.rb +3 -6
  44. data/lib/tuttle/engine.rb +24 -12
  45. data/lib/tuttle/instrumenter.rb +7 -7
  46. data/lib/tuttle/middleware/request_profiler.rb +165 -24
  47. data/lib/tuttle/presenters/action_dispatch/routing/route_wrapper.rb +7 -3
  48. data/lib/tuttle/presenters/rack_mini_profiler/client_settings.rb +27 -0
  49. data/lib/tuttle/ruby_prof/fast_call_stack_printer.rb +26 -53
  50. data/lib/tuttle/version.rb +1 -1
  51. metadata +18 -8
  52. data/app/controllers/tuttle/performance_tuning_controller.rb +0 -14
@@ -1,4 +1,4 @@
1
- <h1>Performance Tuning</h1>
1
+ <h1>Rack MiniProfiler</h1>
2
2
 
3
3
  <dl class="dl-horizontal">
4
4
  <dt>MiniProfiler Version</dt><dd><%= Rack::MiniProfiler::VERSION %></dd>
@@ -16,7 +16,7 @@
16
16
  <% [:auto_inject, :disable_caching, :start_hidden, :skip_schema_queries, :disable_env_dump, :enabled].each do |setting_method| %>
17
17
  <tr>
18
18
  <td><%= setting_method %></td>
19
- <td><%= truth_label(Rack::MiniProfiler.config.send(setting_method)) %></td>
19
+ <td><%= truth_label(@mp_config.send(setting_method)) %></td>
20
20
  <td></td>
21
21
  </tr>
22
22
  <% end %>
@@ -25,7 +25,7 @@
25
25
  :base_url_path, :backtrace_remove, :backtrace_includes, :backtrace_ignores, :backtrace_threshold_ms].each do |setting_method| %>
26
26
  <tr>
27
27
  <td><%= setting_method %></td>
28
- <td><code><%= Rack::MiniProfiler.config.send(setting_method).inspect %></code></td>
28
+ <td><code><%= @mp_config.send(setting_method).inspect %></code></td>
29
29
  <td></td>
30
30
  </tr>
31
31
  <% end %>
@@ -33,7 +33,7 @@
33
33
  <% [ :storage, :storage_options, :storage_instance, :storage_failure, :user_provider, :pre_authorize_cb ].each do |setting_method| %>
34
34
  <tr>
35
35
  <td><%= setting_method %></td>
36
- <td><code><%= Rack::MiniProfiler.config.send(setting_method).inspect %></code></td>
36
+ <td><code><%= @mp_config.send(setting_method).inspect %></code></td>
37
37
  <td></td>
38
38
  </tr>
39
39
  <% end %>
@@ -56,8 +56,8 @@
56
56
  <th>Description</th>
57
57
  </tr>
58
58
  <tr>
59
- <td>has_cookie?</td>
60
- <td><%= truth_label(@mp_client_settings.has_cookie?) %></td>
59
+ <td><%= @mp_client_settings.tuttle_check_cookie_method %></td>
60
+ <td><%= truth_label(@mp_client_settings.tuttle_check_cookie) %></td>
61
61
  <td></td>
62
62
  </tr>
63
63
  <tr>
@@ -0,0 +1,65 @@
1
+ <%
2
+ # Copied from https://github.com/petergoldstein/dalli
3
+ dalli_options = {
4
+ expires_in: "Global default for key TTL. Default is 0, which means no expiry.",
5
+ namespace: "If specified, prepends each key with this value to provide simple namespacing. Default is nil.",
6
+ failover:" Boolean, if true Dalli will failover to another server if the main server for a key is down. Default is true.",
7
+ threadsafe: "Boolean. If true Dalli ensures that only one thread is using a socket at a given time. Default is true. Set to false at your own peril.",
8
+ serializer: "The serializer to use for objects being stored (ex. JSON). Default is Marshal.",
9
+ compress: "Boolean, if true Dalli will gzip-compress values larger than 1K. Default is false.",
10
+ compression_min_size: "Minimum value byte size for which to attempt compression. Default is 1K.",
11
+ compression_max_size: "Maximum value byte size for which to attempt compression. Default is unlimited.",
12
+ compressor: "The compressor to use for objects being stored. Default is zlib, implemented under Dalli::Compressor. If serving compressed data using nginx's HttpMemcachedModule, set memcached_gzip_flag 2 and use Dalli::GzipCompressor",
13
+ keepalive: "Boolean. If true, Dalli will enable keep-alive for socket connections. Default is true.",
14
+ socket_timeout: "Timeout for all socket operations (connect, read, write). Default is 0.5.",
15
+ socket_max_failures: "When a socket operation fails after socket_timeout, the same operation is retried. This is to not immediately mark a server down when there's a very slight network problem. Default is 2.",
16
+ socket_failure_delay: "Before retrying a socket operation, the process sleeps for this amount of time. Default is 0.01. Set to nil for no delay.",
17
+ down_retry_delay: "When a server has been marked down due to many failures, the server will be checked again for being alive only after this amount of time. Don't set this value too low, otherwise each request which tries the failed server might hang for the maximum socket_timeout. Default is 1 second.",
18
+ value_max_bytes: "The maximum size of a value in memcached. Defaults to 1MB, this can be increased with memcached's -I parameter. You must also configure Dalli to allow the larger size here.",
19
+ error_when_over_max_size: "Boolean. If true, Dalli will throw a Dalli::ValueOverMaxSize exception when trying to store data larger than value_max_bytes. Defaults to false, meaning only a warning is logged.",
20
+ username: "The username to use for authenticating this client instance against a SASL-enabled memcached server. Heroku users should not need to use this normally.",
21
+ password: "The password to use for authenticating this client instance against a SASL-enabled memcached server. Heroku users should not need to use this normally.",
22
+ sndbuf: "In bytes, set the socket SO_SNDBUF. Defaults to operating system default.",
23
+ rcvbuf: "In bytes, set the socket SO_RCVBUF. Defaults to operating system default.",
24
+ cache_nils: "Boolean. If true Dalli will not treat cached nil values as 'not found' for #fetch operations. Default is false.",
25
+ }
26
+ # TODO: more specifics on servers and pool (including connection_pool gem)
27
+ %>
28
+
29
+ <h2 id="cache-internals">Dalli/Memcache Options</h2>
30
+ <table class="table table-condensed not-wide">
31
+ <tr>
32
+ <th>Setting</th>
33
+ <th>Option Setting</th>
34
+ <th>Description</th>
35
+ </tr>
36
+ <% dalli_options.each do |key, description| %>
37
+ <tr>
38
+ <td><%= key.inspect %></td>
39
+ <td><code><%= @cache.options[key].inspect %></code></td>
40
+ <td><%= description %></td>
41
+ </tr>
42
+ <% end %>
43
+ </table>
44
+
45
+ <%- if @cache.respond_to?(:stats) %>
46
+ <h4>MemCache Stats</h4>
47
+ <table class="table table-condensed not-wide">
48
+ <tr>
49
+ <th>Stat<br></th>
50
+ <th>Value</th>
51
+ </tr>
52
+ <% @cache.stats.each do |server, stats| %>
53
+ <tr>
54
+ <td colspan="2">Server: <%= server %></td>
55
+ </tr>
56
+ <% stats.each do |k, v| %>
57
+ <tr>
58
+ <td><%= k %></td>
59
+ <td><%= v %></td>
60
+ </tr>
61
+ <% end %>
62
+ <% end %>
63
+ </table>
64
+ <%- end %>
65
+
@@ -0,0 +1,43 @@
1
+ <h2>Memory Store Internals</h2>
2
+ <table class="table table-condensed not-wide">
3
+ <tr>
4
+ <th>Setting</th>
5
+ <th>Value</th>
6
+ <th>Description</th>
7
+ </tr>
8
+ <tr>
9
+ <td>Cache Size</td>
10
+ <td><%= @cache.instance_variable_get(:@cache_size) %></td>
11
+ <td>Size of the entries including keys and overhead</td>
12
+ </tr>
13
+ <tr>
14
+ <td>Max Size</td>
15
+ <td><%= @cache.instance_variable_get(:@max_size) %></td>
16
+ <td>Maximum allowed size which triggers pruning. Default is 32MB.</td>
17
+ </tr>
18
+ <tr>
19
+ <td>Max Prune Time</td>
20
+ <td><%= @cache.instance_variable_get(:@max_prune_time) %></td>
21
+ <td>Time limit for doing pruning</td>
22
+ </tr>
23
+ <tr>
24
+ <td>Entries</td>
25
+ <td><%= @cache.instance_variable_get(:@data).size %></td>
26
+ <td>Total number of active entries</td>
27
+ </tr>
28
+ </table>
29
+
30
+ <% timenow = Time.now.to_f %>
31
+ <h2>Memory Store keys by last access time (seconds ago)</h2>
32
+ <table class="table table-condensed not-wide">
33
+ <tr>
34
+ <th>Last Access<br></th>
35
+ <th>Key</th>
36
+ </tr>
37
+ <% @cache.instance_variable_get(:@key_access).sort_by(&:last).reverse!.each do |k, v| %>
38
+ <tr>
39
+ <td><%= (timenow - v).round(2) %></td>
40
+ <td><%= k %></td>
41
+ </tr>
42
+ <% end %>
43
+ </table>
@@ -0,0 +1,63 @@
1
+ <%- # TODO: Controls
2
+ # Add options here for MemoryStore(clear, cleanup, and prune), FileStore(clear, cleanup), and MemCacheStore(clear).
3
+ # For MemoryStore, provide method to dump keys and Entry attributes for very granular testing
4
+ # For testing/inspection, provide a form to manipulate (add,remove,incr,decr) entries
5
+ # TODO: Track calls and record keys broken down by namespace
6
+ -%>
7
+
8
+ <h2>Monitoring/Instrumentation</h2>
9
+ <%- unless Tuttle.track_notifications %>
10
+ <div class="alert alert-warning" role="alert">
11
+ <p>Note: Tuttle cache instrumentation has not been enabled. Use <code>config.track_notifications=true</code> to enable.</p>
12
+ </div>
13
+ <%- end %>
14
+
15
+ <h3>Recent cache interactions</h3>
16
+ <table class="table">
17
+ <tr>
18
+ <th>Action</th>
19
+ <th>Key</th>
20
+ <th>Hit?</th>
21
+ <th>Options</th>
22
+ <th>Time</th>
23
+ <th>Duration</th>
24
+ <th>TransactionID</th>
25
+ </tr>
26
+ <% @cache_events.reverse.each do |event| -%>
27
+ <tr >
28
+ <td><%= event.name=='cache_read.active_support' ? 'read':'write' %></td>
29
+ <td><%= event.payload[:key] %></td>
30
+ <td><%= event.payload[:hit] %></td>
31
+ <td><%= event.payload.except(:key, :hit) %></td>
32
+ <td><%= event.time.to_s(:db) %></td>
33
+ <td><%= number_with_precision(event.duration) %></td>
34
+ <td><%= event.transaction_id %></td>
35
+ </tr>
36
+ <% end -%>
37
+ </table>
38
+
39
+ <h3>Recent cache call locations</h3>
40
+ <table class="table">
41
+ <tr>
42
+ <th>Action</th>
43
+ <th>File</th>
44
+ <th>Line</th>
45
+ <th>Key</th>
46
+ <th>Hit?</th>
47
+ <th>Options</th>
48
+ <th>Time</th>
49
+ <th>TransactionID</th>
50
+ </tr>
51
+ <% @tuttle_cache_events.reverse.each do |event| -%>
52
+ <tr >
53
+ <td>Read</td>
54
+ <td><%= event.payload[:call_location_path] %></td>
55
+ <td><%= event.payload[:call_location_lineno] %></td>
56
+ <td><%= event.payload[:key] %></td>
57
+ <td><%= event.payload[:hit] %></td>
58
+ <td><%= event.payload.reject {|k,_v| %i(key hit call_location_path call_location_lineno).include?(k) } %></td>
59
+ <td><%= event.time.to_s(:db) %></td>
60
+ <td><%= event.transaction_id %></td>
61
+ </tr>
62
+ <% end -%>
63
+ </table>
@@ -1,40 +1,193 @@
1
- <h2>Assets/Sprockets</h2>
1
+ <h2>Asset Pipeline</h2>
2
+ <%
3
+ # TODO: this should be broken up by intent
4
+ # -setting up CDN
5
+ # -development time
6
+ # Also look for obsolete keys in config.assets (like compress)
7
+ %>
8
+ <p>
9
+ The Asset Pipeline is configured primarily by <code>config.assets.*</code>
10
+ settings. These values are typically set in <code>config/application.rb</code>,
11
+ <code>config/initiailizers/assets.rb</code>, and the different
12
+ <code>config/environments/*</code> files.
13
+ </p>
2
14
 
3
- <%- if @sprockets %>
4
- Sprockets version: <%= Sprockets::VERSION %><br/>
5
- Sprockets::Rails version: <%= Sprockets::Rails::VERSION %><br/>
6
- SASS version: <%= defined?(Sass::VERSION) ? Sass::VERSION : '-' %><br/>
15
+ <p>
16
+ See the Rails Guides for
17
+ <a href="<%= rails_guides_versioned_url('asset_pipeline.html') %>">Asset Pipeline</a>
18
+ and
19
+ <a href="<%= rails_guides_versioned_url('configuring.html#configuring-assets') %>">Configuring Assets</a>
20
+ for a further description of the settings available.
21
+ </p>
22
+
23
+ <%- if @sprockets_env %>
24
+ <h3>Helper Gems</h3>
25
+ Sprockets version: <%= ::Sprockets::VERSION %><br/>
26
+ Sprockets::Rails version: <%= ::Sprockets::Rails::VERSION %><br/>
27
+ Sass::Rails version: <%= defined?(::Sass::Rails::VERSION) ? ::Sass::Rails::VERSION : '-' %><br/>
28
+ Sass version: <%= defined?(::Sass::VERSION) ? Sass::VERSION : '-' %><br/>
7
29
  CoffeeScript version: <%= defined?(CoffeeScript) ? CoffeeScript::version : '-' %><br/>
8
- ECO version: <%= defined?(Eco) ? Eco::version : '-' %><br/>
9
- EJS version: <%= defined?(EJS) ? '1.1.1' : '-' %><br/>
10
30
 
11
31
  <h3>Configuration</h3>
12
- digest: <%= Rails.application.config.assets.digest %><br/>
13
- <%- if Sprockets::VERSION < '3' %>
14
- ** digest value: <%= @sprockets.digest %><br/>
15
- <%- end %>
16
- assets version: <%= Rails.application.config.assets.version %><br/>
17
- ** sprockets assets version: <%= @sprockets.version %><br/>
18
- assets prefix: <%= Rails.application.config.assets.prefix %><br/>
19
- manifest: <%= Rails.application.config.assets.manifest || 'false' %><br/>
20
- debug: <%= Rails.application.config.assets.debug %><br/>
21
- compile: <%= Rails.application.config.assets.compile %><br/>
22
- <%- # NOTE: only in Sprockets 2.x %>
23
- raise_runtime_errors: <%= Rails.application.config.assets.raise_runtime_errors %><br/>
24
- js_compressor: <%= Rails.application.config.assets.js_compressor %><br/>
25
- css_compressor: <%= Rails.application.config.assets.css_compressor %><br/>
26
-
27
- asset_host (for CDNs): <%= Rails.application.config.action_controller.asset_host %><br/>
28
- static_cache_control (for CDNs): <%= Rails.application.config.static_cache_control %><br/>
32
+ <table class="table table-condensed">
33
+ <tr>
34
+ <th>Setting</th>
35
+ <th>Value</th>
36
+ <th>Description</th>
37
+ </tr>
38
+ <tr>
39
+ <td>config.assets.enabled</td>
40
+ <td><code><%= @assets_config.enabled.inspect %></code></td>
41
+ <td>Controls whether the asset pipeline is enabled.</td>
42
+ </tr>
43
+ <tr>
44
+ <td>config.assets.version</td>
45
+ <td><code><%= @assets_config.version.inspect %></code></td>
46
+ <td>Version of your assets, change this if you want to expire all your assets.</td>
47
+ </tr>
48
+ <tr>
49
+ <td>config.assets.prefix</td>
50
+ <td><code><%= @assets_config.prefix.inspect %></code></td>
51
+ <td>Defines the prefix where assets are served from.</td>
52
+ </tr>
53
+ <tr>
54
+ <td>config.assets.manifest</td>
55
+ <td><code><%= @assets_config.manifest.inspect %></code></td>
56
+ <td>If defined, it will be the full path to be used for the asset precompiler's manifest file. Defaults to a file named "manifest-&lt;random&gt;.json"</td>
57
+ </tr>
58
+ <tr>
59
+ <td>config.assets.debug</td>
60
+ <td><code><%= @assets_config.debug.inspect %></code></td>
61
+ <td>Disables the concatenation and compression of assets.</td>
62
+ </tr>
63
+ <tr>
64
+ <td>config.assets.compile</td>
65
+ <td><code><%= @assets_config.compile.inspect %></code></td>
66
+ <td>Enable live compilation. Should be true in development and false in production.</td>
67
+ </tr>
68
+ <tr>
69
+ <td>config.assets.quiet</td>
70
+ <td><code><%= @assets_config.quiet.inspect %></code></td>
71
+ <td>
72
+ If set to true in an environment configuration (not an initializer),
73
+ a Middleware will be added that silences the Logger.
74
+ </td>
75
+ </tr>
76
+ <tr>
77
+ <td>config.assets.resolve_with</td>
78
+ <td><code><%= @assets_config.resolve_with.inspect %></code></td>
79
+ <td></td>
80
+ </tr>
81
+ <tr>
82
+ <td>config.assets.unknown_asset_fallback</td>
83
+ <td><code><%= @assets_config.unknown_asset_fallback.inspect %></code></td>
84
+ <td></td>
85
+ </tr>
86
+ <% if Sprockets::Rails::VERSION >= '3.6.2' %>
87
+ <tr>
88
+ <td>config.assets.check_precompiled_asset</td>
89
+ <td><code><%= @assets_config.check_precompiled_asset.inspect %></code></td>
90
+ <% # Formerly config.assets.raise_runtime_errors - wrong in docs %>
91
+ <td>Set this flag to true to enable additional runtime error checking. Recommended in config/environments/development.rb to minimize unexpected behavior when deploying to production.</td>
92
+ </tr>
93
+ <% end %>
94
+ <tr>
95
+ <td>config.assets.gzip</td>
96
+ <td><code><%= @assets_config.gzip.inspect %></code></td>
97
+ <td>A flag that enables the creation of gzipped version of compiled assets, along with non-gzipped assets.</td>
98
+ </tr>
99
+ <tr>
100
+ <td>config.assets.digest</td>
101
+ <td><code><%= @assets_config.digest.inspect %></code></td>
102
+ <td>Enables the use of MD5 fingerprints in asset names</td>
103
+ </tr>
104
+ <tr>
105
+ <td>config.assets.js_compressor</td>
106
+ <td><code><%= @assets_config.js_compressor.inspect %></code></td>
107
+ <td>Defines the JavaScript compressor to use</td>
108
+ </tr>
109
+ <tr>
110
+ <td>config.assets.css_compressor</td>
111
+ <td><code><%= @assets_config.css_compressor.inspect %></code></td>
112
+ <td>Defines the CSS compressor to use. It is set by default by sass-rails.</td>
113
+ </tr>
114
+ <tr>
115
+ <td>config.assets.cache_limit</td>
116
+ <td>
117
+ <%= ActiveSupport::NumberHelper.number_to_human_size(@assets_config.cache_limit) %>
118
+ </td>
119
+ <td> </td>
120
+ </tr>
121
+ <tr>
122
+ <td>config.action_controller.asset_host</td>
123
+ <td><code><%= Rails.application.config.action_controller.asset_host %></code></td>
124
+ <td>
125
+ Use primarily in production to set a hostname of the CDN.
126
+ Assets will be served with an appropriate scheme based on the request.
127
+ </td>
128
+ </tr>
129
+ <% if Rails::VERSION::MAJOR < 5 %>
130
+ <%
131
+ # Note: in Rails 5 this is config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=31536000' }
132
+ # See http://blog.bigbinary.com/2015/10/31/rails-5-allows-setting-custom-http-headers-for-assets.html
133
+ %>
134
+ <tr>
135
+ <td>config.static_cache_control</td>
136
+ <td><code><%= Rails.application.config.static_cache_control %></code></td>
137
+ <td>In Rails 4, a single Cache-Control header can be configured such as
138
+ <code>'public, max-age=1000'</code>
139
+ </td>
140
+ </tr>
141
+ <% end %>
142
+ </table>
29
143
 
144
+ <% if false # This is working but not tested or complete yet %>
145
+ <h4>Sass-rails Configuration</h4>
146
+ <% Rails.application.config.sass.each do |k, v| %>
147
+ <%= "#{k} = #{v}" %><br>
148
+ <% end %>
149
+ <% end %>
30
150
 
31
151
  <h3>Asset paths</h3>
152
+ <p>
153
+ The assets paths are configured with <code>config.assets.path</code> and are searched
154
+ in order. By default, the directories under <code>app/assets</code>, <code>lib/assets</code>,
155
+ and <code>vendor/assets</code> are included.
156
+ </p>
32
157
  <pre>
33
- <% @sprockets.paths.each do |asset_path| %>
34
- <%= asset_path.to_s %>
35
- <% end %>
158
+ <% @sprockets_env.paths.each do |asset_path| -%>
159
+ <%= asset_path.to_s %>
160
+ <% end -%>
161
+ </pre>
36
162
 
37
- </pre>
163
+ <h3>Precompiles - Explicit and Patterns (<%= @assets_config.precompile.length %> items)</h3>
164
+ <ul>
165
+ <% @assets_config.precompile.each do |asset_path| %>
166
+ <li><%= asset_path %></li>
167
+ <% end -%>
168
+ </ul>
169
+
170
+ <%
171
+ # More potential inspections
172
+ # Rails.application.assets_manifest.filename
173
+ # => "<ROOT>/public/assets/.sprockets-manifest-7df610ba9ea7edfaac06929d79cc8034.json"
174
+ # Exceed-development-local > Rails.application.assets_manifest.directory
175
+ # => "<ROOT>/public/assets"
176
+ # Exceed-development-local > Rails.application.assets_manifest.assets
177
+ # => {}
178
+ # Exceed-development-local > Rails.application.assets_manifest.files
179
+ %>
180
+
181
+ <% # Only supported in Rails 4.1+ %>
182
+ <% if Rails.application.respond_to?(:precompiled_assets) %>
183
+ <% all_precompiles = Rails.application.precompiled_assets %>
184
+ <h3>All precompiled (<%= all_precompiles.length %> assets)</h3>
185
+ <ul>
186
+ <% all_precompiles.sort.each do |asset_path| %>
187
+ <li><%= asset_path %></li>
188
+ <% end -%>
189
+ </ul>
190
+ <% end %>
38
191
 
39
192
  <%- else %>
40
193
  <p>Sprockets does not appear to be enabled for this application.</p>
@@ -1,112 +1,102 @@
1
- <h1>Cache</h1>
1
+ <h1>
2
+ Caching <%= truth_label(ActionController::Base.send(:cache_configured?), 'Enabled', 'Disabled') %>
3
+ </h1>
2
4
 
3
- <h2>Configuration</h2>
4
-
5
- <pre>
6
-
7
- Rails.application.config.action_controller.perform_caching = <%= Rails.application.config.action_controller.perform_caching %>
8
-
9
- Page caching available? <%= !!defined?(ActionController::Caching::Pages) %>
10
- Action caching available? <%= !!defined?(ActionController::Caching::Actions) %>
11
-
12
- Rails.cache class = <%= @cache.class %>
13
- Rails.cache options = <%= @cache.options %>
14
-
15
- Rails.cache standard options
16
- <%- ActiveSupport::Cache::UNIVERSAL_OPTIONS.each do |option| %>
17
- :<%= option.to_s %> = <%= @cache.options[option] %>
18
- <%- end %>
19
-
20
- <%- if @cache.is_a?(ActiveSupport::Cache::MemoryStore) %>
21
- Rails MemoryStore options
22
- :size = <%= @cache.instance_variable_get(:@max_size) %>
23
- :max_prune_time = <%= @cache.instance_variable_get(:@max_prune_time) %>
24
- <%- elsif @cache.is_a?(ActiveSupport::Cache::FileStore) %>
25
- Rails FileStore options
26
- :cache_path = <%= @cache.instance_variable_get(:@cache_path) %>
27
- <%- elsif defined?(Dalli) && @cache.is_a?(ActiveSupport::Cache::MemCacheStore) %>
28
- Rails MemCacheStore options
29
- TBD - can take an array of addresses
30
- <%- elsif defined?(Dalli) && defined?(ActiveSupport::Cache::DalliStore) && @cache.is_a?(ActiveSupport::Cache::DalliStore) %>
31
- DalliStore options
32
- TBD - can take an array of addresses, can use connection_pool gem
33
- <%- end %>
34
- </pre>
35
-
36
- <%- if defined?(Dalli) && @cache.respond_to?(:stats) %>
37
- <h3>MemCache Stats</h3>
38
- <pre>
39
- <%= @cache.stats %>
40
- </pre>
41
- <%- end %>
42
-
43
- <%-
44
- #TODO: Controls
45
- #Add options here for MemoryStore(clear, cleanup, and prune), FileStore(clear, cleanup), and MemCacheStore(clear).
46
- #For MemoryStore, provide method to dump keys and Entry attributes for very granular testing
47
- #For testing/inspection, provide a form to manipulate (add,remove,incr,decr) entries
48
-
49
- -%>
50
-
51
- <h2>Monitoring/Instrumentation</h2>
52
- <%- unless Tuttle.track_notifications %>
53
- <div class="alert alert-warning" role="alert">
54
- <p>Note: Tuttle cache instrumentation has not been enabled. Use <code>config.track_notifications=true</code> to enable.</p>
55
- </div>
56
- <%- end %>
5
+ <p>
6
+ For an in-depth overview of Rails Caching, see the
7
+ <a href="<%= rails_guides_versioned_url('caching_with_rails.html') %>">Caching with Rails</a> guide.
8
+ </p>
57
9
 
58
- <h3>Recent cache interactions</h3>
10
+ <h2>Configuration</h2>
11
+ <p>Rails needs to have caching enabled <em>and</em> a specific cache implementation configured.</p>
59
12
 
60
- <table class="table">
13
+ <table class="table table-condensed not-wide">
61
14
  <tr>
62
- <th>Action</th>
63
- <th>Key</th>
64
- <th>Hit?</th>
65
- <th>Options</th>
66
- <th>Time</th>
67
- <th>Duration</th>
68
- <th>TransactionID</th>
15
+ <th>Setting</th>
16
+ <th>Value</th>
17
+ <th>Description</th>
18
+ </tr>
19
+ <tr>
20
+ <td>config.action_controller.perform_caching</td>
21
+ <td><%= truth_label(Rails.application.config.action_controller.perform_caching) %></td>
22
+ <td>
23
+ Configures whether the application should perform caching or not.
24
+ Typically set to false in development mode, true in production.
25
+ </td>
26
+ </tr>
27
+ <tr>
28
+ <td>config.cache_store</td>
29
+ <td><code><%= Rails.application.config.cache_store.inspect %></code></td>
30
+ <td>
31
+ Configuration parameters that will be used to initialize the cache store.
32
+ </td>
33
+ </tr>
34
+ <tr>
35
+ <td>ENV['RAILS_CACHE_ID']</td>
36
+ <td><code><%= ENV['RAILS_CACHE_ID'].inspect %></code></td>
37
+ <td>Used to generate expanded cache keys in Rails' caching code if present</td>
69
38
  </tr>
70
- <% @cache_events.reverse.each do |event| -%>
71
- <tr >
72
- <td><%= event.name=='cache_read.active_support' ? 'read':'write' %></td>
73
- <td><%= event.payload[:key] %></td>
74
- <td><%= event.payload[:hit] %></td>
75
- <td><%= event.payload.reject {|k,_v| k==:key || k==:hit} %></td>
76
- <td><%= event.time.to_s(:db) %></td>
77
- <td><%= number_with_precision(event.duration) %></td>
78
- <td><%= event.transaction_id %></td>
79
- </tr>
80
- <% end -%>
81
- </table>
82
-
83
- <h3>Recent cache call locations</h3>
84
-
85
- <table class="table">
86
39
  <tr>
87
- <th>Action</th>
88
- <th>File</th>
89
- <th>Line</th>
90
- <th>Key</th>
91
- <th>Hit?</th>
92
- <th>Options</th>
93
- <th>Time</th>
94
- <th>TransactionID</th>
40
+ <td>ENV['RAILS_APP_VERSION']</td>
41
+ <td><code><%= ENV['RAILS_APP_VERSION'].inspect %></code></td>
42
+ <td>Used to generate expanded cache keys in Rails' caching code if present</td>
95
43
  </tr>
96
- <% @tuttle_cache_events.reverse.each do |event| -%>
97
- <tr >
98
- <td>Read</td>
99
- <td><%= event.payload[:call_location_path] %></td>
100
- <td><%= event.payload[:call_location_lineno] %></td>
101
- <td><%= event.payload[:key] %></td>
102
- <td><%= event.payload[:hit] %></td>
103
- <td><%= event.payload.reject {|k,_v| %i(key hit call_location_path call_location_lineno).include?(k) } %></td>
104
- <td><%= event.time.to_s(:db) %></td>
105
- <td><%= event.transaction_id %></td>
44
+ <% if ActionMailer::Base.respond_to?(:perform_caching=) %>
45
+ <tr>
46
+ <td>config.action_mailer.perform_caching</td>
47
+ <td><%= truth_label(Rails.application.config.action_mailer.perform_caching) %></td>
48
+ <td></td>
106
49
  </tr>
107
- <% end -%>
50
+ <% end %>
108
51
  </table>
109
52
 
110
- <%-
111
- # TODO: Track calls and record keys broken down by namespace
112
- -%>
53
+ <% if Rails.application.config.action_controller.perform_caching %>
54
+ <h2>Cache Details</h2>
55
+ <p>
56
+ Rails.cache class = <code><%= @cache.class %></code><br />
57
+ </p>
58
+ <p>
59
+ Rails.cache options = <code><%= @cache.options.inspect %></code>
60
+ </p>
61
+ <p>Rails.cache standard options:<br />
62
+ <%- ActiveSupport::Cache::UNIVERSAL_OPTIONS.each do |option| %>
63
+ &nbsp;&nbsp;<code><%= option.inspect %> =&gt; <%= @cache.options[option].inspect %></code><br />
64
+ <%- end %>
65
+ </p>
66
+
67
+ <%-
68
+ # Page and action caching were removed from Rails and made available in a separate gem
69
+ # https://github.com/rails/actionpack-page_caching
70
+ # https://github.com/rails/actionpack-action_caching
71
+ # Page caching available? <%= !!defined?(ActionController::Caching::Pages)
72
+ # Action caching available? <%= !!defined?(ActionController::Caching::Actions)
73
+ -%>
74
+
75
+ <%- if @cache.is_a?(ActiveSupport::Cache::MemoryStore) %>
76
+ <%= render partial: 'cache_memory_store' %>
77
+ <%- elsif @cache.is_a?(ActiveSupport::Cache::MemCacheStore) ||
78
+ defined?(::ActiveSupport::Cache::DalliStore) && @cache.is_a?(ActiveSupport::Cache::DalliStore) %>
79
+ <%= render partial: 'cache_dalli_store' %>
80
+ <%- elsif @cache.is_a?(ActiveSupport::Cache::FileStore) %>
81
+ <p>
82
+ Rails FileStore options<br />
83
+ &nbsp;&nbsp;<code>:cache_path =&gt; <%= @cache.cache_path %></code>
84
+ </p>
85
+ <%- elsif @cache.is_a?(ActiveSupport::Cache::NullStore) %>
86
+ <p>
87
+ NullStore has no configuration options
88
+ </p>
89
+ <%- else %>
90
+ <p>
91
+ Unknown cache store.
92
+ </p>
93
+ <%- end %>
94
+
95
+ <% # DISABLED render partial: 'cache_monitor' %>
96
+
97
+ <% else %>
98
+ <p>
99
+ Rails is not configured to perform caching in this environment.
100
+ You will need to set <code>config.action_controller.perform_caching = true</code> to enable caching.
101
+ </p>
102
+ <% end %>