rack-mini-profiler 0.1.9 → 0.1.10
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.
- data/CHANGELOG +6 -0
- data/README.md +0 -0
- data/lib/mini_profiler/profiler.rb +46 -9
- data/lib/mini_profiler/timer_struct.rb +6 -1
- data/rack-mini-profiler.gemspec +1 -1
- metadata +4 -4
data/CHANGELOG
CHANGED
data/README.md
CHANGED
File without changes
|
@@ -63,11 +63,26 @@ module Rack
|
|
63
63
|
|
64
64
|
# remove the mini profiler cookie, only used when config.authorization_mode == :whitelist
|
65
65
|
def remove_profiling_cookie(headers)
|
66
|
-
Rack::Utils.
|
66
|
+
Rack::Utils.set_cookie_header!(headers, '__profilin', :value => 'notstylin', :path => '/')
|
67
67
|
end
|
68
68
|
|
69
69
|
def set_profiling_cookie(headers)
|
70
|
-
Rack::Utils.set_cookie_header!(headers, '__profilin', 'stylin')
|
70
|
+
Rack::Utils.set_cookie_header!(headers, '__profilin', :value => 'stylin', :path => '/')
|
71
|
+
end
|
72
|
+
|
73
|
+
# user has the mini profiler cookie, only used when config.authorization_mode == :whitelist
|
74
|
+
def has_disable_profiling_cookie?(env)
|
75
|
+
env['HTTP_COOKIE'] && env['HTTP_COOKIE'].include?("__profilin_disable=stylin")
|
76
|
+
end
|
77
|
+
|
78
|
+
# remove the mini profiler cookie, only used when config.authorization_mode == :whitelist
|
79
|
+
def remove_disable_profiling_cookie(headers)
|
80
|
+
#something is odd with delete_cookie_header
|
81
|
+
Rack::Utils.set_cookie_header!(headers, '__profilin_disable', :value => 'notstylin', :path => '/')
|
82
|
+
end
|
83
|
+
|
84
|
+
def set_disable_profiling_cookie(headers)
|
85
|
+
Rack::Utils.set_cookie_header!(headers, '__profilin_disable', :value => 'stylin', :path => '/')
|
71
86
|
end
|
72
87
|
|
73
88
|
def create_current(env={}, options={})
|
@@ -181,11 +196,12 @@ module Rack
|
|
181
196
|
|
182
197
|
def call(env)
|
183
198
|
status = headers = body = nil
|
199
|
+
query_string = env['QUERY_STRING']
|
184
200
|
path = env['PATH_INFO']
|
185
201
|
|
186
202
|
skip_it = (@config.pre_authorize_cb && !@config.pre_authorize_cb.call(env)) ||
|
187
203
|
(@config.skip_paths && @config.skip_paths.any?{ |p| path[0,p.length] == p}) ||
|
188
|
-
|
204
|
+
query_string =~ /pp=skip/
|
189
205
|
|
190
206
|
has_profiling_cookie = MiniProfiler.has_profiling_cookie?(env)
|
191
207
|
|
@@ -198,13 +214,29 @@ module Rack
|
|
198
214
|
end
|
199
215
|
|
200
216
|
# handle all /mini-profiler requests here
|
201
|
-
return serve_html(env) if
|
217
|
+
return serve_html(env) if path.start_with? @config.base_url_path
|
218
|
+
|
219
|
+
has_disable_cookie = MiniProfiler.has_disable_profiling_cookie?(env)
|
220
|
+
# manual session disable / enable
|
221
|
+
if query_string =~ /pp=disable/ || has_disable_cookie
|
222
|
+
skip_it = true
|
223
|
+
end
|
224
|
+
|
225
|
+
if query_string =~ /pp=enable/
|
226
|
+
skip_it = false
|
227
|
+
end
|
228
|
+
|
229
|
+
if skip_it
|
230
|
+
status,headers,body = @app.call(env)
|
231
|
+
MiniProfiler.set_disable_profiling_cookie(headers) unless has_disable_cookie
|
232
|
+
return [status,headers,body]
|
233
|
+
end
|
202
234
|
|
203
235
|
MiniProfiler.create_current(env, @config)
|
204
236
|
MiniProfiler.deauthorize_request if @config.authorization_mode == :whitelist
|
205
|
-
if
|
237
|
+
if query_string =~ /pp=no-backtrace/
|
206
238
|
current.skip_backtrace = true
|
207
|
-
elsif
|
239
|
+
elsif query_string =~ /pp=full-backtrace/
|
208
240
|
current.full_backtrace = true
|
209
241
|
end
|
210
242
|
|
@@ -212,7 +244,7 @@ module Rack
|
|
212
244
|
quit_sampler = false
|
213
245
|
backtraces = nil
|
214
246
|
missing_stacktrace = false
|
215
|
-
if
|
247
|
+
if query_string =~ /pp=sample/
|
216
248
|
backtraces = []
|
217
249
|
t = Thread.current
|
218
250
|
Thread.new {
|
@@ -240,6 +272,9 @@ module Rack
|
|
240
272
|
start = Time.now
|
241
273
|
begin
|
242
274
|
status,headers,body = @app.call(env)
|
275
|
+
if has_disable_cookie
|
276
|
+
MiniProfiler.remove_disable_profiling_cookie(headers)
|
277
|
+
end
|
243
278
|
ensure
|
244
279
|
if backtraces
|
245
280
|
done_sampling = true
|
@@ -256,12 +291,12 @@ module Rack
|
|
256
291
|
return [status,headers,body] if skip_it
|
257
292
|
|
258
293
|
# we must do this here, otherwise current[:discard] is not being properly treated
|
259
|
-
if
|
294
|
+
if query_string =~ /pp=env/
|
260
295
|
body.close if body.respond_to? :close
|
261
296
|
return dump_env env
|
262
297
|
end
|
263
298
|
|
264
|
-
if
|
299
|
+
if query_string =~ /pp=help/
|
265
300
|
body.close if body.respond_to? :close
|
266
301
|
return help
|
267
302
|
end
|
@@ -348,6 +383,8 @@ module Rack
|
|
348
383
|
pp=no-backtrace : don't collect stack traces from all the SQL executed
|
349
384
|
pp=full-backtrace : enable full backtrace for SQL executed
|
350
385
|
pp=sample : sample stack traces and return a report isolating heavy usage (requires the stacktrace gem)
|
386
|
+
pp=disable : disable profiling for this session
|
387
|
+
pp=enable : enable profiling for this session (if previously disabled)
|
351
388
|
"
|
352
389
|
if (category == :stacktrace)
|
353
390
|
body = "pp=stacktrace requires the stacktrace gem - add gem 'stacktrace' to your Gemfile"
|
data/rack-mini-profiler.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "rack-mini-profiler"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.10"
|
4
4
|
s.summary = "Profiles loading speed for rack applications."
|
5
5
|
s.authors = ["Aleks Totic","Sam Saffron", "Robin Ward"]
|
6
6
|
s.description = "Page loading speed displayed on every page. Optimize while you develop, performance is a feature."
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-mini-profiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-07
|
14
|
+
date: 2012-08-07 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rack
|
@@ -130,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
130
|
version: '0'
|
131
131
|
segments:
|
132
132
|
- 0
|
133
|
-
hash:
|
133
|
+
hash: -296105007
|
134
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
135
|
none: false
|
136
136
|
requirements:
|
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
version: '0'
|
140
140
|
segments:
|
141
141
|
- 0
|
142
|
-
hash:
|
142
|
+
hash: -296105007
|
143
143
|
requirements: []
|
144
144
|
rubyforge_project:
|
145
145
|
rubygems_version: 1.8.24
|