rack-mini-profiler 0.9.0.pre → 0.9.0
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.
- checksums.yaml +4 -4
- data/README.md +23 -1
- data/lib/mini_profiler/profiler.rb +4 -2
- data/lib/mini_profiler/storage/file_store.rb +26 -4
- data/lib/mini_profiler/storage/memory_store.rb +25 -4
- data/lib/patches/sql_patches.rb +2 -1
- data/rack-mini-profiler.gemspec +10 -2
- metadata +116 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 521860df9b65cce4c241d9fed2b68c671fcecdfe
|
4
|
+
data.tar.gz: bc1e39096a4c99ff1eabc31fa94bca57845dc95d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5b6273e7286a487549c2beea765802d30f6e27e7624dd4317c12cb028e8eaa97cac9914e8bb6bb53f12757f1002fa56d513a60adf57f7d3910875ff6784d7de
|
7
|
+
data.tar.gz: cbe7f735f443cb54c209170a32da9c45ded84d0b151e87ba1cc0f113c6cad393390430712e354c88215b7f88a69f540649be033fcdadfbbef44d9d0aacd4305d
|
data/README.md
CHANGED
@@ -15,7 +15,6 @@ The new home for rack-mini-profiler is https://github.com/MiniProfiler/rack-mini
|
|
15
15
|
- Setting up a build that reuses https://github.com/MiniProfiler/ui
|
16
16
|
- Migrating the internal data structures [per the spec](https://github.com/MiniProfiler/ui)
|
17
17
|
- 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)
|
18
|
-
- Add travis-ci testing at least MRI 1.9.3, JRuby and MRI 2.0
|
19
18
|
|
20
19
|
If you feel like taking on any of this start an issue and update us on your progress.
|
21
20
|
|
@@ -190,3 +189,26 @@ end
|
|
190
189
|
|
191
190
|
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.
|
192
191
|
|
192
|
+
## Licence
|
193
|
+
|
194
|
+
The MIT License (MIT)
|
195
|
+
|
196
|
+
Copyright (c) 2013 Sam Saffron
|
197
|
+
|
198
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
199
|
+
of this software and associated documentation files (the "Software"), to deal
|
200
|
+
in the Software without restriction, including without limitation the rights
|
201
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
202
|
+
copies of the Software, and to permit persons to whom the Software is
|
203
|
+
furnished to do so, subject to the following conditions:
|
204
|
+
|
205
|
+
The above copyright notice and this permission notice shall be included in
|
206
|
+
all copies or substantial portions of the Software.
|
207
|
+
|
208
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
209
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
210
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
211
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
212
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
213
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
214
|
+
THE SOFTWARE.
|
@@ -204,7 +204,7 @@ module Rack
|
|
204
204
|
skip_it = true
|
205
205
|
end
|
206
206
|
|
207
|
-
if query_string =~ /pp=enable/
|
207
|
+
if query_string =~ /pp=enable/ && (@config.authorization_mode != :whitelist || MiniProfiler.request_authorized?)
|
208
208
|
skip_it = false
|
209
209
|
config.enabled = true
|
210
210
|
end
|
@@ -283,12 +283,14 @@ module Rack
|
|
283
283
|
current.measure = false
|
284
284
|
match_data = query_string.match(/flamegraph_sample_rate=(?<rate>[\d\.]+)/)
|
285
285
|
|
286
|
+
mode = query_string =~ /mode=c/ ? :c : :ruby
|
287
|
+
|
286
288
|
if match_data && !match_data[:rate].to_f.zero?
|
287
289
|
sample_rate = match_data[:rate].to_f
|
288
290
|
else
|
289
291
|
sample_rate = config.flamegraph_sample_rate
|
290
292
|
end
|
291
|
-
flamegraph = Flamegraph.generate(nil, fidelity: sample_rate, embed_resources: query_string =~ /embed
|
293
|
+
flamegraph = Flamegraph.generate(nil, fidelity: sample_rate, embed_resources: query_string =~ /embed/, mode: mode) do
|
292
294
|
status,headers,body = @app.call(env)
|
293
295
|
end
|
294
296
|
end
|
@@ -2,6 +2,10 @@ module Rack
|
|
2
2
|
class MiniProfiler
|
3
3
|
class FileStore < AbstractStore
|
4
4
|
|
5
|
+
# Sub-class thread so we have a named thread (useful for debugging in Thread.list).
|
6
|
+
class CacheCleanupThread < Thread
|
7
|
+
end
|
8
|
+
|
5
9
|
class FileCache
|
6
10
|
def initialize(path, prefix)
|
7
11
|
@path = path
|
@@ -40,17 +44,35 @@ module Rack
|
|
40
44
|
@user_view_lock = Mutex.new
|
41
45
|
|
42
46
|
me = self
|
43
|
-
|
47
|
+
t = CacheCleanupThread.new do
|
48
|
+
interval = 10
|
49
|
+
cleanup_cache_cycle = 3600
|
50
|
+
cycle_count = 1
|
51
|
+
|
44
52
|
begin
|
45
|
-
|
53
|
+
until Thread.current[:should_exit] do
|
46
54
|
# TODO: a sane retry count before bailing
|
47
|
-
|
48
|
-
|
55
|
+
|
56
|
+
# We don't want to hit the filesystem every 10s to clean up the cache so we need to do a bit of
|
57
|
+
# accounting to avoid sleeping that entire time. We don't want to sleep for the entire period because
|
58
|
+
# it means the thread will stay live in hot deployment scenarios, keeping a potentially large memory
|
59
|
+
# graph from being garbage collected upon undeploy.
|
60
|
+
if cycle_count * interval >= cleanup_cache_cycle
|
61
|
+
cycle_count = 1
|
62
|
+
me.cleanup_cache
|
63
|
+
end
|
64
|
+
|
65
|
+
sleep(interval)
|
66
|
+
cycle_count += 1
|
49
67
|
end
|
50
68
|
rescue
|
51
69
|
# don't crash the thread, we can clean up next time
|
52
70
|
end
|
53
71
|
end
|
72
|
+
|
73
|
+
at_exit { t[:should_exit] = true }
|
74
|
+
|
75
|
+
t
|
54
76
|
end
|
55
77
|
|
56
78
|
def save(page_struct)
|
@@ -2,6 +2,10 @@ module Rack
|
|
2
2
|
class MiniProfiler
|
3
3
|
class MemoryStore < AbstractStore
|
4
4
|
|
5
|
+
# Sub-class thread so we have a named thread (useful for debugging in Thread.list).
|
6
|
+
class CacheCleanupThread < Thread
|
7
|
+
end
|
8
|
+
|
5
9
|
EXPIRES_IN_SECONDS = 60 * 60 * 24
|
6
10
|
|
7
11
|
def initialize(args = nil)
|
@@ -14,12 +18,29 @@ module Rack
|
|
14
18
|
|
15
19
|
# TODO: fix it to use weak ref, trouble is may be broken in 1.9 so need to use the 'ref' gem
|
16
20
|
me = self
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
t = CacheCleanupThread.new do
|
22
|
+
interval = 10
|
23
|
+
cleanup_cache_cycle = 3600
|
24
|
+
cycle_count = 1
|
25
|
+
|
26
|
+
until Thread.current[:should_exit] do
|
27
|
+
# We don't want to hit the filesystem every 10s to clean up the cache so we need to do a bit of
|
28
|
+
# accounting to avoid sleeping that entire time. We don't want to sleep for the entire period because
|
29
|
+
# it means the thread will stay live in hot deployment scenarios, keeping a potentially large memory
|
30
|
+
# graph from being garbage collected upon undeploy.
|
31
|
+
if cycle_count * interval >= cleanup_cache_cycle
|
32
|
+
cycle_count = 1
|
33
|
+
me.cleanup_cache
|
34
|
+
end
|
35
|
+
|
36
|
+
sleep(interval)
|
37
|
+
cycle_count += 1
|
21
38
|
end
|
22
39
|
end
|
40
|
+
|
41
|
+
at_exit { t[:should_exit] = true }
|
42
|
+
|
43
|
+
t
|
23
44
|
end
|
24
45
|
|
25
46
|
def save(page_struct)
|
data/lib/patches/sql_patches.rb
CHANGED
@@ -222,7 +222,8 @@ if SqlPatches.class_exists?("Sequel::Database") && !SqlPatches.patched?
|
|
222
222
|
class Database
|
223
223
|
alias_method :log_duration_original, :log_duration
|
224
224
|
def log_duration(duration, message)
|
225
|
-
|
225
|
+
# `duration` will be in seconds, but we need it in milliseconds for internal consistency.
|
226
|
+
::Rack::MiniProfiler.record_sql(message, duration * 1000)
|
226
227
|
log_duration_original(duration, message)
|
227
228
|
end
|
228
229
|
end
|
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.9.0
|
3
|
+
s.version = "0.9.0"
|
4
4
|
s.summary = "Profiles loading speed for rack applications."
|
5
5
|
s.authors = ["Sam Saffron", "Robin Ward","Aleks Totic"]
|
6
6
|
s.description = "Profiling toolkit for Rack applications with Rails integration. Client Side profiling, DB profiling and Server profiling."
|
@@ -22,6 +22,14 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_development_dependency 'rake'
|
23
23
|
s.add_development_dependency 'rack-test'
|
24
24
|
s.add_development_dependency 'activerecord', '~> 3.0'
|
25
|
+
s.add_development_dependency 'dalli'
|
26
|
+
s.add_development_dependency 'rspec'
|
27
|
+
s.add_development_dependency 'ZenTest'
|
28
|
+
s.add_development_dependency 'autotest'
|
29
|
+
s.add_development_dependency 'redis'
|
30
|
+
s.add_development_dependency 'therubyracer'
|
31
|
+
s.add_development_dependency 'less'
|
32
|
+
s.add_development_dependency 'flamegraph'
|
25
33
|
|
26
34
|
s.require_paths = ["lib"]
|
27
|
-
end
|
35
|
+
end
|
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.9.0
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2014-01-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
@@ -68,6 +68,118 @@ dependencies:
|
|
68
68
|
- - ~>
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '3.0'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: dalli
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: rspec
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: ZenTest
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: autotest
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
type: :development
|
121
|
+
prerelease: false
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: redis
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: therubyracer
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
type: :development
|
149
|
+
prerelease: false
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
- !ruby/object:Gem::Dependency
|
156
|
+
name: less
|
157
|
+
requirement: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - '>='
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
type: :development
|
163
|
+
prerelease: false
|
164
|
+
version_requirements: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - '>='
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
- !ruby/object:Gem::Dependency
|
170
|
+
name: flamegraph
|
171
|
+
requirement: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - '>='
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
176
|
+
type: :development
|
177
|
+
prerelease: false
|
178
|
+
version_requirements: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - '>='
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
71
183
|
description: Profiling toolkit for Rack applications with Rails integration. Client
|
72
184
|
Side profiling, DB profiling and Server profiling.
|
73
185
|
email: sam.saffron@gmail.com
|
@@ -128,9 +240,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
240
|
version: '0'
|
129
241
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
242
|
requirements:
|
131
|
-
- - '
|
243
|
+
- - '>='
|
132
244
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
245
|
+
version: '0'
|
134
246
|
requirements: []
|
135
247
|
rubyforge_project:
|
136
248
|
rubygems_version: 2.0.14
|