rack-mini-profiler 0.1.30 → 0.9.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +149 -0
- data/README.md +271 -0
- data/{Ruby/lib → lib}/html/includes.css +0 -0
- data/{Ruby/lib → lib}/html/includes.js +9 -8
- data/{Ruby/lib → lib}/html/includes.less +0 -0
- data/{Ruby/lib → lib}/html/includes.tmpl +1 -1
- data/{Ruby/lib → lib}/html/jquery.1.7.1.js +0 -0
- data/{Ruby/lib → lib}/html/jquery.tmpl.js +0 -0
- data/{Ruby/lib → lib}/html/list.css +2 -2
- data/{Ruby/lib → lib}/html/list.js +1 -1
- data/{Ruby/lib → lib}/html/list.tmpl +2 -2
- data/lib/html/profile_handler.js +1 -0
- data/{Ruby/lib → lib}/html/share.html +2 -2
- data/{Ruby/lib → lib}/mini_profiler/client_settings.rb +0 -0
- data/{Ruby/lib → lib}/mini_profiler/client_timer_struct.rb +0 -0
- data/{Ruby/lib → lib}/mini_profiler/config.rb +11 -4
- data/{Ruby/lib → lib}/mini_profiler/context.rb +1 -1
- data/{Ruby/lib → lib}/mini_profiler/custom_timer_struct.rb +0 -0
- data/lib/mini_profiler/gc_profiler.rb +181 -0
- data/{Ruby/lib → lib}/mini_profiler/page_timer_struct.rb +0 -0
- data/{Ruby/lib → lib}/mini_profiler/profiler.rb +108 -123
- data/{Ruby/lib → lib}/mini_profiler/profiling_methods.rb +0 -0
- data/{Ruby/lib → lib}/mini_profiler/request_timer_struct.rb +0 -0
- data/{Ruby/lib → lib}/mini_profiler/sql_timer_struct.rb +0 -0
- data/{Ruby/lib → lib}/mini_profiler/storage/abstract_store.rb +0 -0
- data/{Ruby/lib → lib}/mini_profiler/storage/file_store.rb +26 -4
- data/{Ruby/lib → lib}/mini_profiler/storage/memcache_store.rb +0 -0
- data/{Ruby/lib → lib}/mini_profiler/storage/memory_store.rb +25 -4
- data/{Ruby/lib → lib}/mini_profiler/storage/redis_store.rb +0 -0
- data/{Ruby/lib → lib}/mini_profiler/timer_struct.rb +0 -0
- data/lib/mini_profiler/version.rb +5 -0
- data/{Ruby/lib → lib}/mini_profiler_rails/railtie.rb +23 -6
- data/{Ruby/lib → lib}/patches/net_patches.rb +0 -0
- data/{Ruby/lib → lib}/patches/sql_patches.rb +15 -8
- data/{Ruby/lib → lib}/rack-mini-profiler.rb +0 -0
- data/rack-mini-profiler.gemspec +24 -16
- metadata +163 -53
- data/Ruby/CHANGELOG +0 -156
- data/Ruby/README.md +0 -172
- data/Ruby/lib/html/flamegraph.html +0 -351
- data/Ruby/lib/html/profile_handler.js +0 -1
- data/Ruby/lib/mini_profiler/flame_graph.rb +0 -54
- data/Ruby/lib/mini_profiler/gc_profiler.rb +0 -107
- data/Ruby/lib/mini_profiler/version.rb +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8b3ee0b3863448cab4aa77a7d21a6660cd864fdd
|
|
4
|
+
data.tar.gz: 84d03ff97e66376542b2ad7862abcb1e5fee280b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e31c6eacf0d6fa8b01f1c11ef4be1f16a86e1f08843ef79ff8051c5029b78460aa9c23802b1cdc1be8e1b4d19dc19e6644c621740bec0c8578aed6a04bb52ede
|
|
7
|
+
data.tar.gz: cf86b40baacdd86a5e90f641a4ec9e2367ddfef55c3f1810aeed774fd55950b86c428ab9df7eabcd08f09a1dc093b142f270ac3bad4ff7acba4a4b87e1d52826
|
data/CHANGELOG.md
ADDED
|
@@ -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
|
data/README.md
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# rack-mini-profiler
|
|
2
|
+
|
|
3
|
+
[](https://codeclimate.com/github/MiniProfiler/rack-mini-profiler) [](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/sql_timer_struct.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** 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
|
+
### Storage
|
|
116
|
+
|
|
117
|
+
rack-mini-profiler stores its results so they can be shared later and aren't lost at the end of the request.
|
|
118
|
+
|
|
119
|
+
There are 4 storage options: `MemoryStore`, `RedisStore`, `MemcacheStore`, and `FileStore`.
|
|
120
|
+
|
|
121
|
+
`FileStore` is the default in Rails environments and will write files to `tmp/miniprofiler/*`. `MemoryStore` is the default otherwise.
|
|
122
|
+
|
|
123
|
+
```ruby
|
|
124
|
+
# set MemoryStore
|
|
125
|
+
Rack::MiniProfiler.config.storage = Rack::MiniProfiler::MemoryStore
|
|
126
|
+
|
|
127
|
+
# set RedisStore
|
|
128
|
+
if Rails.env.production?
|
|
129
|
+
uri = URI.parse(ENV["REDIS_SERVER_URL"])
|
|
130
|
+
Rack::MiniProfiler.config.storage_options = { :host => uri.host, :port => uri.port, :password => uri.password }
|
|
131
|
+
Rack::MiniProfiler.config.storage = Rack::MiniProfiler::RedisStore
|
|
132
|
+
end
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
MemoryStore stores results in a processes heap - something that does not work well in a multi process environment.
|
|
136
|
+
FileStore stores results in the file system - something that may not work well in a multi machine environment.
|
|
137
|
+
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).
|
|
138
|
+
|
|
139
|
+
Additionally you may implement an AbstractStore for your own provider.
|
|
140
|
+
|
|
141
|
+
### User result segregation
|
|
142
|
+
|
|
143
|
+
MiniProfiler will attempt to keep all user results isolated, out-of-the-box the user provider uses the ip address:
|
|
144
|
+
|
|
145
|
+
```ruby
|
|
146
|
+
Rack::MiniProfiler.config.user_provider = Proc.new{|env| Rack::Request.new(env).ip}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
You can override (something that is very important in a multi-machine production setup):
|
|
150
|
+
|
|
151
|
+
```ruby
|
|
152
|
+
Rack::MiniProfiler.config.user_provider = Proc.new{ |env| CurrentUser.get(env) }
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
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)
|
|
156
|
+
|
|
157
|
+
### Configuration Options
|
|
158
|
+
|
|
159
|
+
You can set configuration options using the configuration accessor on `Rack::MiniProfiler`.
|
|
160
|
+
For example:
|
|
161
|
+
|
|
162
|
+
```ruby
|
|
163
|
+
Rack::MiniProfiler.config.position = 'right'
|
|
164
|
+
Rack::MiniProfiler.config.start_hidden = true
|
|
165
|
+
```
|
|
166
|
+
The available configuration options are:
|
|
167
|
+
|
|
168
|
+
* 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.
|
|
169
|
+
* position - Can either be 'right' or 'left'. Default is 'left'.
|
|
170
|
+
* 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.
|
|
171
|
+
* auto_inject (default true) - when false the miniprofiler script is not injected in the page
|
|
172
|
+
* backtrace_filter - a regex you can use to filter out unwanted lines from the backtraces
|
|
173
|
+
* 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.
|
|
174
|
+
* start_hidden (default false) - Whether or not you want the mini_profiler to be visible when loading a page
|
|
175
|
+
* 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.
|
|
176
|
+
* flamegraph_sample_rate (default 0.5ms) - How often fast_stack should get stack trace info to generate flamegraphs
|
|
177
|
+
|
|
178
|
+
### Custom middleware ordering (required if using `Rack::Deflate` with Rails)
|
|
179
|
+
|
|
180
|
+
If you are using `Rack::Deflate` with rails and rack-mini-profiler in its default configuration,
|
|
181
|
+
`Rack::MiniProfiler` will be injected (as always) at position 0 in the middleware stack. This
|
|
182
|
+
will result in it attempting to inject html into the already-compressed response body. To fix this,
|
|
183
|
+
the middleware ordering must be overriden.
|
|
184
|
+
|
|
185
|
+
To do this, first add `, require: false` to the gemfile entry for rack-mini-profiler.
|
|
186
|
+
This will prevent the railtie from running. Then, customize the initialization
|
|
187
|
+
in the initializer like so:
|
|
188
|
+
|
|
189
|
+
```ruby
|
|
190
|
+
require 'rack-mini-profiler'
|
|
191
|
+
|
|
192
|
+
Rack::MiniProfilerRails.initialize!(Rails.application)
|
|
193
|
+
|
|
194
|
+
Rails.application.middleware.delete(Rack::MiniProfiler)
|
|
195
|
+
Rails.application.middleware.insert_after(Rack::Deflater, Rack::MiniProfiler)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Deleting the middleware and then reinserting it is a bit inelegant, but
|
|
199
|
+
a sufficient and costless solution. It is possible that rack-mini-profiler might
|
|
200
|
+
support this scenario more directly if it is found that
|
|
201
|
+
there is significant need for this confriguration or that
|
|
202
|
+
the above recipe causes problems.
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
## Special query strings
|
|
206
|
+
|
|
207
|
+
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.
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
## Rails 2.X support
|
|
211
|
+
|
|
212
|
+
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.
|
|
213
|
+
|
|
214
|
+
Add the following code to your environment.rb (or just in a specific environment such as development.rb) for initialization and configuration of MiniProfiler.
|
|
215
|
+
|
|
216
|
+
```ruby
|
|
217
|
+
# configure and initialize MiniProfiler
|
|
218
|
+
require 'rack-mini-profiler'
|
|
219
|
+
c = ::Rack::MiniProfiler.config
|
|
220
|
+
c.pre_authorize_cb = lambda { |env|
|
|
221
|
+
Rails.env.development? || Rails.env.production?
|
|
222
|
+
}
|
|
223
|
+
tmp = Rails.root.to_s + "/tmp/miniprofiler"
|
|
224
|
+
FileUtils.mkdir_p(tmp) unless File.exists?(tmp)
|
|
225
|
+
c.storage_options = {:path => tmp}
|
|
226
|
+
c.storage = ::Rack::MiniProfiler::FileStore
|
|
227
|
+
config.middleware.use(::Rack::MiniProfiler)
|
|
228
|
+
::Rack::MiniProfiler.profile_method(ActionController::Base, :process) {|action| "Executing action: #{action}"}
|
|
229
|
+
::Rack::MiniProfiler.profile_method(ActionView::Template, :render) {|x,y| "Rendering: #{path_without_format_and_extension}"}
|
|
230
|
+
|
|
231
|
+
# monkey patch away an activesupport and json_pure incompatability
|
|
232
|
+
# http://pivotallabs.com/users/alex/blog/articles/1332-monkey-patch-of-the-day-activesupport-vs-json-pure-vs-ruby-1-8
|
|
233
|
+
if JSON.const_defined?(:Pure)
|
|
234
|
+
class JSON::Pure::Generator::State
|
|
235
|
+
include ActiveSupport::CoreExtensions::Hash::Except
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Running the Specs
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
$ rake build
|
|
244
|
+
$ rake spec
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Additionally you can also run `autotest` if you like.
|
|
248
|
+
|
|
249
|
+
## Licence
|
|
250
|
+
|
|
251
|
+
The MIT License (MIT)
|
|
252
|
+
|
|
253
|
+
Copyright (c) 2013 Sam Saffron
|
|
254
|
+
|
|
255
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
256
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
257
|
+
in the Software without restriction, including without limitation the rights
|
|
258
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
259
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
260
|
+
furnished to do so, subject to the following conditions:
|
|
261
|
+
|
|
262
|
+
The above copyright notice and this permission notice shall be included in
|
|
263
|
+
all copies or substantial portions of the Software.
|
|
264
|
+
|
|
265
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
266
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
267
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
268
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
269
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
270
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
271
|
+
THE SOFTWARE.
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
var MiniProfiler = (function () {
|
|
3
3
|
var $;
|
|
4
4
|
|
|
@@ -659,6 +659,14 @@ var MiniProfiler = (function () {
|
|
|
659
659
|
} else {
|
|
660
660
|
doInit();
|
|
661
661
|
}
|
|
662
|
+
|
|
663
|
+
// jquery.hotkeys.js
|
|
664
|
+
// https://github.com/jeresig/jquery.hotkeys/blob/master/jquery.hotkeys.js
|
|
665
|
+
|
|
666
|
+
(function(d){function h(g){if("string"===typeof g.data){var h=g.handler,j=g.data.toLowerCase().split(" ");g.handler=function(b){if(!(this!==b.target&&(/textarea|select/i.test(b.target.nodeName)||"text"===b.target.type))){var c="keypress"!==b.type&&d.hotkeys.specialKeys[b.which],e=String.fromCharCode(b.which).toLowerCase(),a="",f={};b.altKey&&"alt"!==c&&(a+="alt+");b.ctrlKey&&"ctrl"!==c&&(a+="ctrl+");b.metaKey&&(!b.ctrlKey&&"meta"!==c)&&(a+="meta+");b.shiftKey&&"shift"!==c&&(a+="shift+");c?f[a+c]=
|
|
667
|
+
!0:(f[a+e]=!0,f[a+d.hotkeys.shiftNums[e]]=!0,"shift+"===a&&(f[d.hotkeys.shiftNums[e]]=!0));c=0;for(e=j.length;c<e;c++)if(f[j[c]])return h.apply(this,arguments)}}}}d.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",
|
|
668
|
+
109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",191:"/",224:"meta"},shiftNums:{"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(","0":")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}};d.each(["keydown","keyup","keypress"],function(){d.event.special[this]={add:h}})})(MiniProfiler.jQuery);
|
|
669
|
+
|
|
662
670
|
};
|
|
663
671
|
|
|
664
672
|
var major, minor;
|
|
@@ -901,13 +909,6 @@ var MiniProfiler = (function () {
|
|
|
901
909
|
|
|
902
910
|
MiniProfiler.init();
|
|
903
911
|
|
|
904
|
-
// jquery.hotkeys.js
|
|
905
|
-
// https://github.com/jeresig/jquery.hotkeys/blob/master/jquery.hotkeys.js
|
|
906
|
-
|
|
907
|
-
(function(d){function h(g){if("string"===typeof g.data){var h=g.handler,j=g.data.toLowerCase().split(" ");g.handler=function(b){if(!(this!==b.target&&(/textarea|select/i.test(b.target.nodeName)||"text"===b.target.type))){var c="keypress"!==b.type&&d.hotkeys.specialKeys[b.which],e=String.fromCharCode(b.which).toLowerCase(),a="",f={};b.altKey&&"alt"!==c&&(a+="alt+");b.ctrlKey&&"ctrl"!==c&&(a+="ctrl+");b.metaKey&&(!b.ctrlKey&&"meta"!==c)&&(a+="meta+");b.shiftKey&&"shift"!==c&&(a+="shift+");c?f[a+c]=
|
|
908
|
-
!0:(f[a+e]=!0,f[a+d.hotkeys.shiftNums[e]]=!0,"shift+"===a&&(f[d.hotkeys.shiftNums[e]]=!0));c=0;for(e=j.length;c<e;c++)if(f[j[c]])return h.apply(this,arguments)}}}}d.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",
|
|
909
|
-
109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",191:"/",224:"meta"},shiftNums:{"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(","0":")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}};d.each(["keydown","keyup","keypress"],function(){d.event.special[this]={add:h}})})(jQuery);
|
|
910
|
-
|
|
911
912
|
if (typeof prettyPrint === "undefined") {
|
|
912
913
|
|
|
913
914
|
// prettify.js
|