rack-mini-profiler 0.1.31 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rack-mini-profiler might be problematic. Click here for more details.

Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +149 -0
  3. data/README.md +285 -0
  4. data/{Ruby/lib → lib}/html/includes.css +15 -4
  5. data/{Ruby/lib → lib}/html/includes.js +95 -59
  6. data/{Ruby/lib → lib}/html/includes.less +21 -5
  7. data/{Ruby/lib → lib}/html/includes.tmpl +50 -50
  8. data/{Ruby/lib → lib}/html/jquery.1.7.1.js +0 -0
  9. data/{Ruby/lib → lib}/html/jquery.tmpl.js +0 -0
  10. data/{Ruby/lib → lib}/html/list.css +2 -2
  11. data/{Ruby/lib → lib}/html/list.js +1 -1
  12. data/lib/html/list.tmpl +34 -0
  13. data/lib/html/profile_handler.js +1 -0
  14. data/{Ruby/lib → lib}/html/share.html +2 -2
  15. data/lib/mini_profiler/asset_version.rb +5 -0
  16. data/{Ruby/lib → lib}/mini_profiler/client_settings.rb +3 -3
  17. data/lib/mini_profiler/config.rb +65 -0
  18. data/{Ruby/lib → lib}/mini_profiler/context.rb +0 -0
  19. data/lib/mini_profiler/gc_profiler.rb +181 -0
  20. data/{Ruby/lib → lib}/mini_profiler/profiler.rb +120 -96
  21. data/{Ruby/lib → lib}/mini_profiler/profiling_methods.rb +15 -17
  22. data/{Ruby/lib → lib}/mini_profiler/storage/abstract_store.rb +0 -0
  23. data/{Ruby/lib → lib}/mini_profiler/storage/file_store.rb +30 -8
  24. data/{Ruby/lib → lib}/mini_profiler/storage/memcache_store.rb +5 -7
  25. data/lib/mini_profiler/storage/memory_store.rb +115 -0
  26. data/{Ruby/lib → lib}/mini_profiler/storage/redis_store.rb +19 -11
  27. data/lib/mini_profiler/timer_struct/base.rb +33 -0
  28. data/lib/mini_profiler/timer_struct/client.rb +89 -0
  29. data/lib/mini_profiler/timer_struct/custom.rb +22 -0
  30. data/lib/mini_profiler/timer_struct/page.rb +62 -0
  31. data/lib/mini_profiler/timer_struct/request.rb +126 -0
  32. data/lib/mini_profiler/timer_struct/sql.rb +59 -0
  33. data/lib/mini_profiler/version.rb +5 -0
  34. data/{Ruby/lib → lib}/mini_profiler_rails/railtie.rb +23 -6
  35. data/lib/patches/db/activerecord.rb +42 -0
  36. data/lib/patches/db/moped.rb +12 -0
  37. data/lib/patches/db/mysql2.rb +30 -0
  38. data/lib/patches/db/pg.rb +104 -0
  39. data/lib/patches/db/plucky.rb +47 -0
  40. data/lib/patches/db/rsolr.rb +24 -0
  41. data/lib/patches/db/sequel.rb +10 -0
  42. data/{Ruby/lib → lib}/patches/net_patches.rb +0 -0
  43. data/lib/patches/sql_patches.rb +46 -0
  44. data/lib/rack-mini-profiler.rb +35 -0
  45. data/rack-mini-profiler.gemspec +28 -16
  46. metadata +171 -52
  47. data/Ruby/CHANGELOG +0 -161
  48. data/Ruby/README.md +0 -172
  49. data/Ruby/lib/html/list.tmpl +0 -34
  50. data/Ruby/lib/html/profile_handler.js +0 -1
  51. data/Ruby/lib/mini_profiler/client_timer_struct.rb +0 -78
  52. data/Ruby/lib/mini_profiler/config.rb +0 -58
  53. data/Ruby/lib/mini_profiler/custom_timer_struct.rb +0 -22
  54. data/Ruby/lib/mini_profiler/gc_profiler.rb +0 -107
  55. data/Ruby/lib/mini_profiler/gc_profiler_ruby_head.rb +0 -40
  56. data/Ruby/lib/mini_profiler/page_timer_struct.rb +0 -58
  57. data/Ruby/lib/mini_profiler/request_timer_struct.rb +0 -115
  58. data/Ruby/lib/mini_profiler/sql_timer_struct.rb +0 -58
  59. data/Ruby/lib/mini_profiler/storage/memory_store.rb +0 -65
  60. data/Ruby/lib/mini_profiler/timer_struct.rb +0 -33
  61. data/Ruby/lib/mini_profiler/version.rb +0 -5
  62. data/Ruby/lib/patches/sql_patches.rb +0 -277
  63. data/Ruby/lib/rack-mini-profiler.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50a96f45043bb94f118971de9fe539a5af648d9c
4
- data.tar.gz: 2deba7160023f7ae64ec39bdc456bcaf2c77fb45
3
+ metadata.gz: 915cfa4f71cab960c3f73128fa213cce013f0b65
4
+ data.tar.gz: 3465e843ef28ed50178f1f76255de96b474903f6
5
5
  SHA512:
6
- metadata.gz: 4444d3a819342722b3e27d8de3d9cbf9687fa3d54f9d9f39214ccb405b05973cc68950687227f3ea7caa4d994f0d6f757b4f34122c24a95689f9563b97e844a2
7
- data.tar.gz: 2a9bdaf1850ca648c2569994f680874ce79bd5351553ce4d1c802119923ac375cddf4ba9d67812a2d4db1e06562af5672a9318aff678a84eef5896a3897b3907
6
+ metadata.gz: 7c232ba029fb050b15d6b4cdb08b9dc3a6079ed723c06beb7b99dcbc7b6d009822aa2686895661a8e57497a0c5e529a691bf7507c0a895639be9b0e0346ddf29
7
+ data.tar.gz: 45b90274fd6828441a1a4ca14017a6d3b1f1292b65c157dbd03964748b7fd648b39f06484b36d56fd0340b52498bd9c8b0242fe6063e6e23dd115d4b99c10040
@@ -0,0 +1,149 @@
1
+ # CHANGELOG
2
+ ## 0.9.2 - 2014-06-26 (Sam Saffron)
3
+ - [CHANGE] staging and other environments behave like production (Cedric Felizard)
4
+ - [DOC] CHANGELOG reorg (Olivier Lacan)
5
+ - [FIXED] Double calls to Rack::MiniProfilerRails.initialize! now raise an exception (Julik Tarkhanov)
6
+ - [FIXED] Add no-store header (George Mendoza)
7
+
8
+ ## 0.9.1 - 2014-03-13 (Sam Saffron)
9
+ - [ADDED] Added back Ruby 1.8 support (thanks Malet)
10
+ - [IMPROVED] Amended Railstie so MiniProfiler can be launched with action view or action controller (Thanks Akira)
11
+ - [FIXED] Rails 3.0 support (thanks Zlatko)
12
+ - [FIXED] Possible XSS (admin only)
13
+ - [FIXED] Corrected Sql patching to avoid setting instance vars on nil which is frozen (thanks Andy, huoxito)
14
+
15
+ ## 0.9.0.pre - 2013-12-12 (Sam Saffron)
16
+ - Bumped up version to reflect the stability of the project
17
+ - [IMPROVED] Reports for pp=profile-gc
18
+ - [IMPROVED] pp=flamegraph&flamegraph_sample_rate=1 , allow you to specify sampling rates
19
+
20
+ ## 2013-09-17 (Ross Wilson)
21
+ - [IMPROVED] Instead of supressing all "/assets/" requests we now check the configured
22
+ config.assets.prefix path since developers can rename the path to serve Asset Pipeline
23
+ files from
24
+
25
+ ## 2013-09-03
26
+ - [IMPROVED] Flamegraph now has much increased fidelity
27
+ - [REMOVED] Ripped out flamegraph so it can be isolated into a gem
28
+ - [REMOVED] Ripped out pp=sample it just was never really used
29
+
30
+ ## 1.30 - 2013-08-30
31
+ - [ADDED] Rack::MiniProfiler.counter_method(klass,name) for injecting counters
32
+ - [FIXED] Counters were not shifting the table correctly
33
+
34
+ ## 1.29 - 2013-08-20
35
+ - [ADDED] Implemented exception tracing using TracePoint see pp=trace-exceptions
36
+ - [FIXED] SOLR patching had an incorrect monkey patch
37
+
38
+ ## 1.28 - 2012-07-18
39
+ - [FIXED] Diagnostics in abstract storage was raising not implemented killing
40
+ ?pp=env and others
41
+ - [FIXED] SOLR xml unescaped by mistake
42
+
43
+ ## 1.27 - 2013-06-26
44
+ - [ADDED] Rack::MiniProfiler.config.backtrace_threshold_ms
45
+ - [ADDED] jQuery 2.0 support
46
+ - [FIXED] Disabled global ajax handlers on MP requests @JP
47
+
48
+ ## 1.26 - 2013-04-11
49
+ - [IMPROVED] Allow Rack::MiniProfilerRails.initialize!(Rails.application), for post config intialization
50
+
51
+ ## 1.25 - 2013-04-08
52
+ - [FIXED] Missed flamegraph.html from build
53
+
54
+ ## 1.24 - 2013-04-08
55
+ - [ADDED] Flame Graph Support see: http://samsaffron.com/archive/2013/03/19/flame-graphs-in-ruby-miniprofiler
56
+ - [ADDED] New toggle_shortcut and start_hidden options
57
+ - [ADDED] Mongoid support
58
+ - [ADDED] Rack::MiniProfiler.counter counter_name {}
59
+ - [ADDED] Net:HTTP profiling
60
+ - [ADDED] Ruby 1.8.7 support ... grrr
61
+ - [IMPROVED] More robust gc profiling
62
+ - [IMPROVED] Script tag initialized via data-attributes
63
+ - [IMPROVED] Allow usage of existing jQuery if its already loaded
64
+ - [IMPROVED] Pre-authorize to run in all non development? and production? modes
65
+ - [FIXED] AngularJS support and MooTools
66
+ - [FIXED] File retention leak in file_store
67
+ - [FIXED] HTML5 implicit <body> tags
68
+ - [FIXED] pp=enable
69
+
70
+ ## 1.22 - 2012-09-20
71
+ - [FIXED] Permission issue in the gem
72
+
73
+ ## 17-September-2012
74
+ - [IMPROVED] Allow rack-mini-profiler to be sourced from github
75
+ - [IMPROVED] Extracted the pp=profile-gc-time out, the object space profiler needs to disable gc
76
+
77
+ ## 1.21 - 2012-09-17
78
+ - [ADDED] New MemchacedStore
79
+ - [ADDED] Rails 4 support
80
+
81
+ ## 2012-09-12 (Sam Saffron)
82
+ - [ADDED] pp=profile-gc: allows you to profile the GC in Ruby 1.9.3
83
+
84
+ ## 1.19 - 2012-09-10 (Sam Saffron)
85
+ - [FIXED] Compatibility issue with Ruby 1.8.7
86
+
87
+ ## 1.17 - 2012-09-09 (Sam Saffron)
88
+ - [FIXED] pp=sample was bust unless stacktrace was installed
89
+
90
+ ## 1.16 - 2012-09-05 (Sam Saffron)
91
+ - [IMPROVED] Implemented stacktrace properly
92
+ - [FIXED] Long standing problem specs (issue with memory store)
93
+ - [FIXED] Issue where profiler would be dumped when you got a 404 in production (and any time rails is bypassed)
94
+
95
+ ## 1.15.pre - 2012-09-04 (Sam Saffron)
96
+ - [FIXED] Annoying bug where client settings were not sticking
97
+ - [FIXED] Long standing issue with Rack::ConditionalGet stopping MiniProfiler from working properly
98
+
99
+ ## 1.13.pre - 2012-09-03 (Sam Saffron)
100
+ - [ADDED] Setting: config.backtrace_ignores = [] - an array of regexes that match on caller lines that get ignored
101
+ - [ADDED] Setting: config.backtrace_includes = [] - an array of regexes that get included in the trace by default
102
+ - [ADDED] pp=normal-backtrace to clear the "sticky" state
103
+ - [IMPROVED] Cleaned up the way client settings are stored
104
+ - [IMPROVED] Made pp=full-backtrace "sticky"
105
+ - [IMPROVED] Changed "pp=sample" to work with "caller" no need for stack trace gem
106
+ - [FIXED] pg gem prepared statements were not being logged correctly
107
+
108
+ ## 1.12.pre - 2012-08-20 (Sam Saffron)
109
+ - [IMPROVED] Cap X-MiniProfiler-Ids at 10, otherwise the header can get killed
110
+
111
+ ## 2012-08-10 (Sam Saffron)
112
+ - [ADDED] Basic prepared statement profiling for Postgres
113
+
114
+ ## 2012-08-07 (Sam Saffron)
115
+ - [ADDED] Option to disable profiler for the current session (pp=disable / pp=enable)
116
+ - [ADDED] yajl compatability contributed by Sven Riedel
117
+
118
+ ## 0.1.9 - 2012-07-30 (Sam Saffron)
119
+ - [IMPROVED] Made compliant with ancient versions of Rack (including Rack used by Rails2)
120
+ - [FIXED] Broken share link
121
+ - [FIXED] Crashes on startup (in MemoryStore and FileStore)
122
+ - [FIXED] Unicode issue
123
+
124
+ ## 0.1.7 - 2012-07-18 (Sam Saffron)
125
+ - [ADDED] First Paint time for Google Chrome
126
+ - [FIXED] Ensure non Rails installs have mini profiler
127
+
128
+ ## 2012-07-12 (Sam Saffron)
129
+ - [ADDED] Native PG and MySql2 interceptors, this gives way more accurate times
130
+ - [ADDED] some more client probing built in to rails
131
+ - [IMPROVED] Refactored context so its a proper class and not a hash
132
+ - [IMPROVED] More tests
133
+ - [FIXED] Incorrect profiling steps (was not indenting or measuring start time right
134
+
135
+ ## 0.1.3 - 2012-07-09 (Sam Saffron)
136
+ - [ADDED] New option to display full backtraces pp=full-backtrace
137
+ - [IMPROVED] Cleaned up mechanism for profiling in production, all you need to do now
138
+ is call Rack::MiniProfiler.authorize_request to get profiling working in
139
+ production
140
+ - [IMPROVED] Cleaned up railties, got rid of the post authorize callback
141
+
142
+ ## 2012-06-28 (Sam Saffron)
143
+ - [ADDED] Started change log
144
+ - [ADDED] added MemcacheStore
145
+ - [IMPROVED] Corrected profiler so it properly captures POST requests (was supressing non 200s)
146
+ - [IMPROVED] Amended Rack.MiniProfiler.config[:user_provider] to use ip addres for identity
147
+ - [IMPROVED] Supress all '/assets/' in the rails tie (makes debugging easier)
148
+ - [FIXED] Issue where unviewed missing ids never got cleared
149
+ - [FIXED] record_sql was mega buggy
@@ -0,0 +1,285 @@
1
+ # rack-mini-profiler
2
+
3
+ [![Code Climate](https://codeclimate.com/github/MiniProfiler/rack-mini-profiler/badges/gpa.svg)](https://codeclimate.com/github/MiniProfiler/rack-mini-profiler) [![Build Status](https://travis-ci.org/MiniProfiler/rack-mini-profiler.svg)](https://travis-ci.org/MiniProfiler/rack-mini-profiler)
4
+
5
+ Middleware that displays speed badge for every html page. Designed to work both in production and in development.
6
+
7
+ #### Features
8
+
9
+ * database profiling. Currently supports Mysql2, Postgres, and Mongoid3 (with fallback support to ActiveRecord)
10
+
11
+ #### Learn more
12
+
13
+ * [Visit our community](http://community.miniprofiler.com)
14
+ * [Watch the RailsCast](http://railscasts.com/episodes/368-miniprofiler)
15
+ * [Read about Flame graphs in rack-mini-profiler](http://samsaffron.com/archive/2013/03/19/flame-graphs-in-ruby-miniprofiler)
16
+ * [Read the announcement posts from 2012](http://samsaffron.com/archive/2012/07/12/miniprofiler-ruby-edition)
17
+
18
+ ## rack-mini-profiler needs your help
19
+
20
+ We have decided to restructure our repository so there is a central UI repo and the various language implementation have their own.
21
+
22
+ **WE NEED HELP.**
23
+
24
+ - Setting up a build that reuses https://github.com/MiniProfiler/ui
25
+ - Migrating the internal data structures [per the spec](https://github.com/MiniProfiler/ui)
26
+ - Cleaning up the [horrendous class structure that is using strings as keys and crazy non-objects](https://github.com/MiniProfiler/rack-mini-profiler/blob/master/lib/mini_profiler/timer_struct/sql.rb#L36-L44)
27
+
28
+ If you feel like taking on any of this start an issue and update us on your progress.
29
+
30
+ ## Installation
31
+
32
+ Install/add to Gemfile
33
+
34
+ ```ruby
35
+ gem 'rack-mini-profiler'
36
+ ```
37
+
38
+ NOTE: Be sure to require rack_mini_profiler below the `pg` and `mysql` gems in your Gemfile. rack_mini_profiler will identify these gems if they are loaded to insert instrumentation. If included too early no SQL will show up.
39
+
40
+ #### Rails
41
+
42
+ All you have to do is include the Gem and you're good to go in development. See notes below for use in production.
43
+
44
+ #### Rails and manual initialization
45
+
46
+ In case you need to make sure rack_mini_profiler initialized after all other gems.
47
+ Or you want to execute some code before rack_mini_profiler required.
48
+
49
+ ```ruby
50
+ gem 'rack-mini-profiler', require: false
51
+ ```
52
+ Note the `require: false` part - if omitted, it will cause the Railtie for the mini-profiler to
53
+ be loaded outright, and an attempt to re-initialize it manually will raise an exception.
54
+
55
+ Then put initialize code in file like `config/initializers/rack_profiler.rb`
56
+
57
+ ```ruby
58
+ if Rails.env == 'development'
59
+ require 'rack-mini-profiler'
60
+
61
+ # initialization is skipped so trigger it
62
+ Rack::MiniProfilerRails.initialize!(Rails.application)
63
+ end
64
+ ```
65
+
66
+ #### Rack Builder
67
+
68
+ ```ruby
69
+ require 'rack-mini-profiler'
70
+ builder = Rack::Builder.new do
71
+ use Rack::MiniProfiler
72
+
73
+ map('/') { run get }
74
+ end
75
+ ```
76
+
77
+ #### Sinatra
78
+
79
+ ```ruby
80
+ require 'rack-mini-profiler'
81
+ class MyApp < Sinatra::Base
82
+ use Rack::MiniProfiler
83
+ end
84
+ ```
85
+
86
+ ### Flamegraphs
87
+
88
+ To generate [flamegraphs](http://samsaffron.com/archive/2013/03/19/flame-graphs-in-ruby-miniprofiler):
89
+
90
+ * add the [**flamegraph**](https://github.com/SamSaffron/flamegraph) gem to your Gemfile
91
+ * visit a page in your app with `?pp=flamegraph`
92
+
93
+ Flamegraph generation is supported in MRI 2.0 and 2.1 only.
94
+
95
+
96
+ ## Access control in production
97
+
98
+ rack-mini-profiler is designed with production profiling in mind. To enable that just run `Rack::MiniProfiler.authorize_request` once you know a request is allowed to profile.
99
+
100
+ ```ruby
101
+ # A hook in your ApplicationController
102
+ def authorize
103
+ if current_user.is_admin?
104
+ Rack::MiniProfiler.authorize_request
105
+ end
106
+ end
107
+ ```
108
+
109
+ ## Configuration
110
+
111
+ Various aspects of rack-mini-profiler's behavior can be configured when your app boots.
112
+ For example in a Rails app, this should be done in an initializer:
113
+ **config/initializers/mini_profiler.rb**
114
+
115
+ ### Caching behavior
116
+ To fix some nasty bugs with rack-mini-profiler showing the wrong data, the middleware
117
+ will remove headers relating to caching (Date & Etag on responses, If-Modified-Since & If-None-Match on requests).
118
+ This probably won't ever break your application, but it can cause some unexpected behavior. For
119
+ example, in a Rails app, calls to `stale?` will always return true.
120
+
121
+ To disable this behavior, use the following config setting:
122
+
123
+ ```ruby
124
+ # Do not let rack-mini-profiler disable caching
125
+ Rack::MiniProfiler.config.disable_caching = false # defaults to true
126
+ ```
127
+
128
+ ### Storage
129
+
130
+ rack-mini-profiler stores its results so they can be shared later and aren't lost at the end of the request.
131
+
132
+ There are 4 storage options: `MemoryStore`, `RedisStore`, `MemcacheStore`, and `FileStore`.
133
+
134
+ `FileStore` is the default in Rails environments and will write files to `tmp/miniprofiler/*`. `MemoryStore` is the default otherwise.
135
+
136
+ ```ruby
137
+ # set MemoryStore
138
+ Rack::MiniProfiler.config.storage = Rack::MiniProfiler::MemoryStore
139
+
140
+ # set RedisStore
141
+ if Rails.env.production?
142
+ uri = URI.parse(ENV["REDIS_SERVER_URL"])
143
+ Rack::MiniProfiler.config.storage_options = { :host => uri.host, :port => uri.port, :password => uri.password }
144
+ Rack::MiniProfiler.config.storage = Rack::MiniProfiler::RedisStore
145
+ end
146
+ ```
147
+
148
+ MemoryStore stores results in a processes heap - something that does not work well in a multi process environment.
149
+ FileStore stores results in the file system - something that may not work well in a multi machine environment.
150
+ RedisStore/MemcacheStore work in multi process and multi machine environments (RedisStore only saves results for up to 24 hours so it won't continue to fill up Redis).
151
+
152
+ Additionally you may implement an AbstractStore for your own provider.
153
+
154
+ ### User result segregation
155
+
156
+ MiniProfiler will attempt to keep all user results isolated, out-of-the-box the user provider uses the ip address:
157
+
158
+ ```ruby
159
+ Rack::MiniProfiler.config.user_provider = Proc.new{|env| Rack::Request.new(env).ip}
160
+ ```
161
+
162
+ You can override (something that is very important in a multi-machine production setup):
163
+
164
+ ```ruby
165
+ Rack::MiniProfiler.config.user_provider = Proc.new{ |env| CurrentUser.get(env) }
166
+ ```
167
+
168
+ The string this function returns should be unique for each user on the system (for anonymous you may need to fall back to ip address)
169
+
170
+ ### Configuration Options
171
+
172
+ You can set configuration options using the configuration accessor on `Rack::MiniProfiler`.
173
+ For example:
174
+
175
+ ```ruby
176
+ Rack::MiniProfiler.config.position = 'right'
177
+ Rack::MiniProfiler.config.start_hidden = true
178
+ ```
179
+ The available configuration options are:
180
+
181
+ * pre_authorize_cb - A lambda callback you can set to determine whether or not mini_profiler should be visible on a given request. Default in a Rails environment is only on in development mode. If in a Rack app, the default is always on.
182
+ * position - Can either be 'right' or 'left'. Default is 'left'.
183
+ * skip_paths - Specifies path list that can be skipped.
184
+ * skip_schema_queries - Whether or not you want to log the queries about the schema of your tables. Default is 'false', 'true' in rails development.
185
+ * auto_inject (default true) - when false the miniprofiler script is not injected in the page
186
+ * backtrace_filter - a regex you can use to filter out unwanted lines from the backtraces
187
+ * toggle_shortcut (default Alt+P) - a jquery.hotkeys.js-style keyboard shortcut, used to toggle the mini_profiler's visibility. See http://code.google.com/p/js-hotkeys/ for more info.
188
+ * start_hidden (default false) - Whether or not you want the mini_profiler to be visible when loading a page
189
+ * backtrace_threshold_ms (default zero) - Minimum SQL query elapsed time before a backtrace is recorded. Backtrace recording can take a couple of milliseconds on rubies earlier than 2.0, impacting performance for very small queries.
190
+ * flamegraph_sample_rate (default 0.5ms) - How often fast_stack should get stack trace info to generate flamegraphs
191
+
192
+ ### Custom middleware ordering (required if using `Rack::Deflate` with Rails)
193
+
194
+ If you are using `Rack::Deflate` with rails and rack-mini-profiler in its default configuration,
195
+ `Rack::MiniProfiler` will be injected (as always) at position 0 in the middleware stack. This
196
+ will result in it attempting to inject html into the already-compressed response body. To fix this,
197
+ the middleware ordering must be overriden.
198
+
199
+ To do this, first add `, require: false` to the gemfile entry for rack-mini-profiler.
200
+ This will prevent the railtie from running. Then, customize the initialization
201
+ in the initializer like so:
202
+
203
+ ```ruby
204
+ require 'rack-mini-profiler'
205
+
206
+ Rack::MiniProfilerRails.initialize!(Rails.application)
207
+
208
+ Rails.application.middleware.delete(Rack::MiniProfiler)
209
+ Rails.application.middleware.insert_after(Rack::Deflater, Rack::MiniProfiler)
210
+ ```
211
+
212
+ Deleting the middleware and then reinserting it is a bit inelegant, but
213
+ a sufficient and costless solution. It is possible that rack-mini-profiler might
214
+ support this scenario more directly if it is found that
215
+ there is significant need for this confriguration or that
216
+ the above recipe causes problems.
217
+
218
+
219
+ ## Special query strings
220
+
221
+ If you include the query string `pp=help` at the end of your request you will see the various options available. You can use these options to extend or contract the amount of diagnostics rack-mini-profiler gathers.
222
+
223
+
224
+ ## Rails 2.X support
225
+
226
+ To get MiniProfiler working with Rails 2.3.X you need to do the initialization manually as well as monkey patch away an incompatibility between activesupport and json_pure.
227
+
228
+ Add the following code to your environment.rb (or just in a specific environment such as development.rb) for initialization and configuration of MiniProfiler.
229
+
230
+ ```ruby
231
+ # configure and initialize MiniProfiler
232
+ require 'rack-mini-profiler'
233
+ c = ::Rack::MiniProfiler.config
234
+ c.pre_authorize_cb = lambda { |env|
235
+ Rails.env.development? || Rails.env.production?
236
+ }
237
+ tmp = Rails.root.to_s + "/tmp/miniprofiler"
238
+ FileUtils.mkdir_p(tmp) unless File.exists?(tmp)
239
+ c.storage_options = {:path => tmp}
240
+ c.storage = ::Rack::MiniProfiler::FileStore
241
+ config.middleware.use(::Rack::MiniProfiler)
242
+ ::Rack::MiniProfiler.profile_method(ActionController::Base, :process) {|action| "Executing action: #{action}"}
243
+ ::Rack::MiniProfiler.profile_method(ActionView::Template, :render) {|x,y| "Rendering: #{path_without_format_and_extension}"}
244
+
245
+ # monkey patch away an activesupport and json_pure incompatability
246
+ # http://pivotallabs.com/users/alex/blog/articles/1332-monkey-patch-of-the-day-activesupport-vs-json-pure-vs-ruby-1-8
247
+ if JSON.const_defined?(:Pure)
248
+ class JSON::Pure::Generator::State
249
+ include ActiveSupport::CoreExtensions::Hash::Except
250
+ end
251
+ end
252
+ ```
253
+
254
+ ## Running the Specs
255
+
256
+ ```
257
+ $ rake build
258
+ $ rake spec
259
+ ```
260
+
261
+ Additionally you can also run `autotest` if you like.
262
+
263
+ ## Licence
264
+
265
+ The MIT License (MIT)
266
+
267
+ Copyright (c) 2013 Sam Saffron
268
+
269
+ Permission is hereby granted, free of charge, to any person obtaining a copy
270
+ of this software and associated documentation files (the "Software"), to deal
271
+ in the Software without restriction, including without limitation the rights
272
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
273
+ copies of the Software, and to permit persons to whom the Software is
274
+ furnished to do so, subject to the following conditions:
275
+
276
+ The above copyright notice and this permission notice shall be included in
277
+ all copies or substantial portions of the Software.
278
+
279
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
280
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
281
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
282
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
283
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
284
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
285
+ THE SOFTWARE.
@@ -149,6 +149,21 @@
149
149
  .profiler-result .profiler-queries .profiler-stack-trace {
150
150
  margin-bottom: 15px;
151
151
  }
152
+ .profiler-result .profiler-queries tbody tr {
153
+ border-bottom: 1px solid #f1f1f1;
154
+ }
155
+ .profiler-result .profiler-queries tr {
156
+ background-color: #FFF;
157
+ }
158
+ .profiler-result .profiler-queries tr.slow {
159
+ background-color: #FEE;
160
+ }
161
+ .profiler-result .profiler-queries tr.very-slow {
162
+ background-color: #FDD;
163
+ }
164
+ .profiler-result .profiler-queries tr.very-very-slow {
165
+ background-color: #FCC;
166
+ }
152
167
  .profiler-result .profiler-queries pre {
153
168
  font-family: Consolas, monospace, serif;
154
169
  white-space: pre-wrap;
@@ -163,14 +178,10 @@
163
178
  .profiler-result .profiler-queries td {
164
179
  padding: 15px;
165
180
  text-align: left;
166
- background-color: #fff;
167
181
  }
168
182
  .profiler-result .profiler-queries td:last-child {
169
183
  padding-right: 25px;
170
184
  }
171
- .profiler-result .profiler-queries .profiler-odd td {
172
- background-color: #e5e5e5;
173
- }
174
185
  .profiler-result .profiler-queries .profiler-since-start,
175
186
  .profiler-result .profiler-queries .profiler-duration {
176
187
  text-align: right;