speed_gun 1.0.0.rc1 → 2.0.0.pre.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +9 -18
- data/.rspec +1 -1
- data/.rubocop.yml +61 -1
- data/.travis.yml +3 -4
- data/LICENSE.txt +17 -18
- data/README.md +19 -137
- data/Rakefile +9 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/example/rails/.gitignore +18 -0
- data/example/rails/Gemfile +20 -0
- data/example/rails/Gemfile.lock +184 -0
- data/example/rails/README.rdoc +28 -0
- data/example/rails/Rakefile +6 -0
- data/example/rails/app/assets/images/.keep +0 -0
- data/example/rails/app/assets/javascripts/application.js +15 -0
- data/example/rails/app/assets/javascripts/posts.coffee +3 -0
- data/example/rails/app/assets/stylesheets/application.css +15 -0
- data/example/rails/app/assets/stylesheets/posts.scss +3 -0
- data/example/rails/app/assets/stylesheets/scaffolds.scss +73 -0
- data/example/rails/app/controllers/application_controller.rb +5 -0
- data/example/rails/app/controllers/concerns/.keep +0 -0
- data/example/rails/app/controllers/posts_controller.rb +74 -0
- data/example/rails/app/helpers/application_helper.rb +2 -0
- data/example/rails/app/helpers/posts_helper.rb +2 -0
- data/example/rails/app/mailers/.keep +0 -0
- data/example/rails/app/models/.keep +0 -0
- data/example/rails/app/models/concerns/.keep +0 -0
- data/example/rails/app/models/post.rb +2 -0
- data/example/rails/app/views/layouts/application.html.erb +14 -0
- data/example/rails/app/views/posts/_form.html.erb +25 -0
- data/example/rails/app/views/posts/edit.html.erb +6 -0
- data/example/rails/app/views/posts/index.html.erb +29 -0
- data/example/rails/app/views/posts/index.json.jbuilder +4 -0
- data/example/rails/app/views/posts/new.html.erb +5 -0
- data/example/rails/app/views/posts/show.html.erb +14 -0
- data/example/rails/app/views/posts/show.json.jbuilder +1 -0
- data/example/rails/bin/bundle +3 -0
- data/example/rails/bin/rails +9 -0
- data/example/rails/bin/rake +9 -0
- data/example/rails/bin/setup +29 -0
- data/example/rails/bin/spring +15 -0
- data/example/rails/config/application.rb +26 -0
- data/example/rails/config/boot.rb +3 -0
- data/example/rails/config/database.yml +25 -0
- data/example/rails/config/environment.rb +5 -0
- data/example/rails/config/environments/development.rb +41 -0
- data/example/rails/config/environments/production.rb +79 -0
- data/example/rails/config/environments/test.rb +42 -0
- data/example/rails/config/initializers/assets.rb +11 -0
- data/example/rails/config/initializers/backtrace_silencers.rb +7 -0
- data/example/rails/config/initializers/cookies_serializer.rb +3 -0
- data/example/rails/config/initializers/filter_parameter_logging.rb +4 -0
- data/example/rails/config/initializers/inflections.rb +16 -0
- data/example/rails/config/initializers/mime_types.rb +4 -0
- data/example/rails/config/initializers/session_store.rb +3 -0
- data/example/rails/config/initializers/wrap_parameters.rb +14 -0
- data/example/rails/config/locales/en.yml +23 -0
- data/example/rails/config/routes.rb +57 -0
- data/example/rails/config/secrets.yml +22 -0
- data/example/rails/config.ru +4 -0
- data/example/rails/db/migrate/20160619175824_create_posts.rb +10 -0
- data/example/rails/db/schema.rb +23 -0
- data/example/rails/db/seeds.rb +7 -0
- data/example/rails/lib/assets/.keep +0 -0
- data/example/rails/lib/tasks/.keep +0 -0
- data/example/rails/log/.keep +0 -0
- data/example/rails/public/404.html +67 -0
- data/example/rails/public/422.html +67 -0
- data/example/rails/public/500.html +66 -0
- data/example/rails/public/favicon.ico +0 -0
- data/example/rails/public/robots.txt +5 -0
- data/example/rails/test/controllers/.keep +0 -0
- data/example/rails/test/controllers/posts_controller_test.rb +49 -0
- data/example/rails/test/fixtures/.keep +0 -0
- data/example/rails/test/fixtures/posts.yml +9 -0
- data/example/rails/test/helpers/.keep +0 -0
- data/example/rails/test/integration/.keep +0 -0
- data/example/rails/test/mailers/.keep +0 -0
- data/example/rails/test/models/.keep +0 -0
- data/example/rails/test/models/post_test.rb +7 -0
- data/example/rails/test/test_helper.rb +10 -0
- data/example/rails/vendor/assets/javascripts/.keep +0 -0
- data/example/rails/vendor/assets/stylesheets/.keep +0 -0
- data/lib/rack/speed_gun.rb +100 -0
- data/lib/speed_gun/app/public/report.js +58 -0
- data/lib/speed_gun/app/views/events.slim +11 -0
- data/lib/speed_gun/app/views/payload.slim +20 -0
- data/lib/speed_gun/app/views/report.scss +322 -0
- data/lib/speed_gun/app/views/report.slim +57 -0
- data/lib/speed_gun/app.rb +53 -0
- data/lib/speed_gun/config.rb +25 -32
- data/lib/speed_gun/event.rb +29 -39
- data/lib/speed_gun/profiler/action_controller_profiler.rb +3 -8
- data/lib/speed_gun/profiler/action_mailer_profiler.rb +7 -0
- data/lib/speed_gun/profiler/action_view_profiler.rb +3 -8
- data/lib/speed_gun/profiler/active_job_profiler.rb +6 -0
- data/lib/speed_gun/profiler/active_record_profiler.rb +3 -8
- data/lib/speed_gun/profiler/active_support_notifications_profiler.rb +9 -6
- data/lib/speed_gun/profiler/active_support_profiler.rb +8 -0
- data/lib/speed_gun/profiler/line_profiler.rb +32 -0
- data/lib/speed_gun/profiler/rack_profiler.rb +2 -4
- data/lib/speed_gun/profiler.rb +15 -9
- data/lib/speed_gun/railtie.rb +21 -5
- data/lib/speed_gun/report.rb +65 -0
- data/lib/speed_gun/source.rb +90 -0
- data/lib/speed_gun/store/file_store.rb +35 -0
- data/lib/speed_gun/store/memory_store.rb +7 -14
- data/lib/speed_gun/store.rb +10 -3
- data/lib/speed_gun/version.rb +9 -1
- data/lib/speed_gun.rb +21 -26
- data/speed_gun.gemspec +21 -16
- metadata +168 -58
- data/.coveralls.yml +0 -1
- data/lib/speed_gun/app/views/meter.html.slim +0 -4
- data/lib/speed_gun/middleware.rb +0 -91
- data/lib/speed_gun/profile.rb +0 -102
- data/lib/speed_gun/store/elastic_search_store.rb +0 -64
- data/lib/speed_gun/store/fluent_logger_store.rb +0 -29
- data/lib/speed_gun/store/memcache_store.rb +0 -40
- data/lib/speed_gun/store/multiple_store.rb +0 -23
- data/lib/speed_gun/store/redis_store.rb +0 -41
- data/lib/speed_gun/template.rb +0 -15
- data/spec/lib/speed_gun/config_spec.rb +0 -37
- data/spec/lib/speed_gun/event_spec.rb +0 -70
- data/spec/lib/speed_gun/middleware_spec.rb +0 -65
- data/spec/lib/speed_gun/profile_spec.rb +0 -41
- data/spec/lib/speed_gun_spec.rb +0 -52
- data/spec/spec_helper.rb +0 -9
- data/spec/support/simplecov.rb +0 -12
metadata
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: speed_gun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.pre.alpha.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Kusano
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: msgpack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
|
-
type: :
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
@@ -25,13 +25,13 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
|
-
type: :
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
@@ -39,41 +39,41 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rblineprof
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
type: :
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: sass
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0
|
62
|
-
type: :
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: semantic
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
|
-
type: :
|
76
|
+
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
@@ -81,13 +81,13 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: sinatra
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
|
-
type: :
|
90
|
+
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
@@ -95,13 +95,13 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: sinatra-partial
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
|
-
type: :
|
104
|
+
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: slim
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -123,13 +123,55 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: bundler
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.12'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.12'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rake
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '11.0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '11.0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rspec
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '3.0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '3.0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rubocop
|
127
169
|
requirement: !ruby/object:Gem::Requirement
|
128
170
|
requirements:
|
129
171
|
- - ">="
|
130
172
|
- !ruby/object:Gem::Version
|
131
173
|
version: '0'
|
132
|
-
type: :
|
174
|
+
type: :development
|
133
175
|
prerelease: false
|
134
176
|
version_requirements: !ruby/object:Gem::Requirement
|
135
177
|
requirements:
|
@@ -137,13 +179,13 @@ dependencies:
|
|
137
179
|
- !ruby/object:Gem::Version
|
138
180
|
version: '0'
|
139
181
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
182
|
+
name: yard
|
141
183
|
requirement: !ruby/object:Gem::Requirement
|
142
184
|
requirements:
|
143
185
|
- - ">="
|
144
186
|
- !ruby/object:Gem::Version
|
145
187
|
version: '0'
|
146
|
-
type: :
|
188
|
+
type: :development
|
147
189
|
prerelease: false
|
148
190
|
version_requirements: !ruby/object:Gem::Requirement
|
149
191
|
requirements:
|
@@ -152,12 +194,11 @@ dependencies:
|
|
152
194
|
version: '0'
|
153
195
|
description: Better web app profiler for Rails apps
|
154
196
|
email:
|
155
|
-
-
|
197
|
+
- sho-kusano@zeny.io
|
156
198
|
executables: []
|
157
199
|
extensions: []
|
158
200
|
extra_rdoc_files: []
|
159
201
|
files:
|
160
|
-
- ".coveralls.yml"
|
161
202
|
- ".gitignore"
|
162
203
|
- ".rspec"
|
163
204
|
- ".rubocop.yml"
|
@@ -166,37 +207,112 @@ files:
|
|
166
207
|
- LICENSE.txt
|
167
208
|
- README.md
|
168
209
|
- Rakefile
|
210
|
+
- bin/console
|
211
|
+
- bin/setup
|
212
|
+
- example/rails/.gitignore
|
213
|
+
- example/rails/Gemfile
|
214
|
+
- example/rails/Gemfile.lock
|
215
|
+
- example/rails/README.rdoc
|
216
|
+
- example/rails/Rakefile
|
217
|
+
- example/rails/app/assets/images/.keep
|
218
|
+
- example/rails/app/assets/javascripts/application.js
|
219
|
+
- example/rails/app/assets/javascripts/posts.coffee
|
220
|
+
- example/rails/app/assets/stylesheets/application.css
|
221
|
+
- example/rails/app/assets/stylesheets/posts.scss
|
222
|
+
- example/rails/app/assets/stylesheets/scaffolds.scss
|
223
|
+
- example/rails/app/controllers/application_controller.rb
|
224
|
+
- example/rails/app/controllers/concerns/.keep
|
225
|
+
- example/rails/app/controllers/posts_controller.rb
|
226
|
+
- example/rails/app/helpers/application_helper.rb
|
227
|
+
- example/rails/app/helpers/posts_helper.rb
|
228
|
+
- example/rails/app/mailers/.keep
|
229
|
+
- example/rails/app/models/.keep
|
230
|
+
- example/rails/app/models/concerns/.keep
|
231
|
+
- example/rails/app/models/post.rb
|
232
|
+
- example/rails/app/views/layouts/application.html.erb
|
233
|
+
- example/rails/app/views/posts/_form.html.erb
|
234
|
+
- example/rails/app/views/posts/edit.html.erb
|
235
|
+
- example/rails/app/views/posts/index.html.erb
|
236
|
+
- example/rails/app/views/posts/index.json.jbuilder
|
237
|
+
- example/rails/app/views/posts/new.html.erb
|
238
|
+
- example/rails/app/views/posts/show.html.erb
|
239
|
+
- example/rails/app/views/posts/show.json.jbuilder
|
240
|
+
- example/rails/bin/bundle
|
241
|
+
- example/rails/bin/rails
|
242
|
+
- example/rails/bin/rake
|
243
|
+
- example/rails/bin/setup
|
244
|
+
- example/rails/bin/spring
|
245
|
+
- example/rails/config.ru
|
246
|
+
- example/rails/config/application.rb
|
247
|
+
- example/rails/config/boot.rb
|
248
|
+
- example/rails/config/database.yml
|
249
|
+
- example/rails/config/environment.rb
|
250
|
+
- example/rails/config/environments/development.rb
|
251
|
+
- example/rails/config/environments/production.rb
|
252
|
+
- example/rails/config/environments/test.rb
|
253
|
+
- example/rails/config/initializers/assets.rb
|
254
|
+
- example/rails/config/initializers/backtrace_silencers.rb
|
255
|
+
- example/rails/config/initializers/cookies_serializer.rb
|
256
|
+
- example/rails/config/initializers/filter_parameter_logging.rb
|
257
|
+
- example/rails/config/initializers/inflections.rb
|
258
|
+
- example/rails/config/initializers/mime_types.rb
|
259
|
+
- example/rails/config/initializers/session_store.rb
|
260
|
+
- example/rails/config/initializers/wrap_parameters.rb
|
261
|
+
- example/rails/config/locales/en.yml
|
262
|
+
- example/rails/config/routes.rb
|
263
|
+
- example/rails/config/secrets.yml
|
264
|
+
- example/rails/db/migrate/20160619175824_create_posts.rb
|
265
|
+
- example/rails/db/schema.rb
|
266
|
+
- example/rails/db/seeds.rb
|
267
|
+
- example/rails/lib/assets/.keep
|
268
|
+
- example/rails/lib/tasks/.keep
|
269
|
+
- example/rails/log/.keep
|
270
|
+
- example/rails/public/404.html
|
271
|
+
- example/rails/public/422.html
|
272
|
+
- example/rails/public/500.html
|
273
|
+
- example/rails/public/favicon.ico
|
274
|
+
- example/rails/public/robots.txt
|
275
|
+
- example/rails/test/controllers/.keep
|
276
|
+
- example/rails/test/controllers/posts_controller_test.rb
|
277
|
+
- example/rails/test/fixtures/.keep
|
278
|
+
- example/rails/test/fixtures/posts.yml
|
279
|
+
- example/rails/test/helpers/.keep
|
280
|
+
- example/rails/test/integration/.keep
|
281
|
+
- example/rails/test/mailers/.keep
|
282
|
+
- example/rails/test/models/.keep
|
283
|
+
- example/rails/test/models/post_test.rb
|
284
|
+
- example/rails/test/test_helper.rb
|
285
|
+
- example/rails/vendor/assets/javascripts/.keep
|
286
|
+
- example/rails/vendor/assets/stylesheets/.keep
|
287
|
+
- lib/rack/speed_gun.rb
|
169
288
|
- lib/speed_gun.rb
|
170
|
-
- lib/speed_gun/app
|
289
|
+
- lib/speed_gun/app.rb
|
290
|
+
- lib/speed_gun/app/public/report.js
|
291
|
+
- lib/speed_gun/app/views/events.slim
|
292
|
+
- lib/speed_gun/app/views/payload.slim
|
293
|
+
- lib/speed_gun/app/views/report.scss
|
294
|
+
- lib/speed_gun/app/views/report.slim
|
171
295
|
- lib/speed_gun/config.rb
|
172
296
|
- lib/speed_gun/event.rb
|
173
|
-
- lib/speed_gun/middleware.rb
|
174
|
-
- lib/speed_gun/profile.rb
|
175
297
|
- lib/speed_gun/profiler.rb
|
176
298
|
- lib/speed_gun/profiler/action_controller_profiler.rb
|
299
|
+
- lib/speed_gun/profiler/action_mailer_profiler.rb
|
177
300
|
- lib/speed_gun/profiler/action_view_profiler.rb
|
301
|
+
- lib/speed_gun/profiler/active_job_profiler.rb
|
178
302
|
- lib/speed_gun/profiler/active_record_profiler.rb
|
179
303
|
- lib/speed_gun/profiler/active_support_notifications_profiler.rb
|
304
|
+
- lib/speed_gun/profiler/active_support_profiler.rb
|
305
|
+
- lib/speed_gun/profiler/line_profiler.rb
|
180
306
|
- lib/speed_gun/profiler/rack_profiler.rb
|
181
307
|
- lib/speed_gun/railtie.rb
|
308
|
+
- lib/speed_gun/report.rb
|
309
|
+
- lib/speed_gun/source.rb
|
182
310
|
- lib/speed_gun/store.rb
|
183
|
-
- lib/speed_gun/store/
|
184
|
-
- lib/speed_gun/store/fluent_logger_store.rb
|
185
|
-
- lib/speed_gun/store/memcache_store.rb
|
311
|
+
- lib/speed_gun/store/file_store.rb
|
186
312
|
- lib/speed_gun/store/memory_store.rb
|
187
|
-
- lib/speed_gun/store/multiple_store.rb
|
188
|
-
- lib/speed_gun/store/redis_store.rb
|
189
|
-
- lib/speed_gun/template.rb
|
190
313
|
- lib/speed_gun/version.rb
|
191
|
-
- spec/lib/speed_gun/config_spec.rb
|
192
|
-
- spec/lib/speed_gun/event_spec.rb
|
193
|
-
- spec/lib/speed_gun/middleware_spec.rb
|
194
|
-
- spec/lib/speed_gun/profile_spec.rb
|
195
|
-
- spec/lib/speed_gun_spec.rb
|
196
|
-
- spec/spec_helper.rb
|
197
|
-
- spec/support/simplecov.rb
|
198
314
|
- speed_gun.gemspec
|
199
|
-
homepage: https://github.com/
|
315
|
+
homepage: https://github.com/zeny-io/speed_gun
|
200
316
|
licenses:
|
201
317
|
- MIT
|
202
318
|
metadata: {}
|
@@ -216,15 +332,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
216
332
|
version: 1.3.1
|
217
333
|
requirements: []
|
218
334
|
rubyforge_project:
|
219
|
-
rubygems_version: 2.
|
335
|
+
rubygems_version: 2.5.1
|
220
336
|
signing_key:
|
221
337
|
specification_version: 4
|
222
338
|
summary: Better web app profiler for Rails apps
|
223
|
-
test_files:
|
224
|
-
|
225
|
-
- spec/lib/speed_gun/event_spec.rb
|
226
|
-
- spec/lib/speed_gun/middleware_spec.rb
|
227
|
-
- spec/lib/speed_gun/profile_spec.rb
|
228
|
-
- spec/lib/speed_gun_spec.rb
|
229
|
-
- spec/spec_helper.rb
|
230
|
-
- spec/support/simplecov.rb
|
339
|
+
test_files: []
|
340
|
+
has_rdoc:
|
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service_name: travis-ci
|
data/lib/speed_gun/middleware.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'speed_gun'
|
2
|
-
require 'speed_gun/template'
|
3
|
-
require 'speed_gun/profiler/rack_profiler'
|
4
|
-
|
5
|
-
class SpeedGun::Middleware
|
6
|
-
BODY_END_REGEXP = /<\/(?:body|html)>/i
|
7
|
-
|
8
|
-
# @param app [#call] Rack application
|
9
|
-
# @return [SpeedGun::Middleware] a instance of SpeedGun::Middleware
|
10
|
-
def initialize(app)
|
11
|
-
@app = app
|
12
|
-
end
|
13
|
-
|
14
|
-
# Handle rack request
|
15
|
-
#
|
16
|
-
# @return [Rack::Response]
|
17
|
-
def call(env)
|
18
|
-
if with_speed_gun?(env)
|
19
|
-
call_with_speed_gun(env)
|
20
|
-
else
|
21
|
-
call_without_speed_gun(env)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def with_speed_gun?(env)
|
28
|
-
SpeedGun.enabled? && !skip?(env['PATH_INFO'])
|
29
|
-
end
|
30
|
-
|
31
|
-
def skip?(path)
|
32
|
-
SpeedGun.config.skip_paths.any? { |regexp| regexp.match(path) }
|
33
|
-
end
|
34
|
-
|
35
|
-
def call_without_speed_gun(env)
|
36
|
-
@app.call(env)
|
37
|
-
end
|
38
|
-
|
39
|
-
def call_with_speed_gun(env)
|
40
|
-
SpeedGun.current_profile = SpeedGun::Profile.new
|
41
|
-
SpeedGun.current_profile.request_method = env['REQUEST_METHOD'].to_s.upcase
|
42
|
-
SpeedGun.current_profile.path = env['PATH_INFO'].to_s
|
43
|
-
SpeedGun.current_profile.query = env['QUERY_STRING'].to_s
|
44
|
-
|
45
|
-
response = SpeedGun::Profiler::RackProfier.profile do
|
46
|
-
call_without_speed_gun(env)
|
47
|
-
end
|
48
|
-
|
49
|
-
SpeedGun.current_profile.status = response[0]
|
50
|
-
|
51
|
-
if SpeedGun.current_profile.active?
|
52
|
-
inject_header(response[1])
|
53
|
-
if SpeedGun.current_profile.config.auto_inject?
|
54
|
-
response = inject_body(*response)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
response
|
59
|
-
ensure
|
60
|
-
if SpeedGun.current_profile.active?
|
61
|
-
SpeedGun.config.store.save(SpeedGun.current_profile)
|
62
|
-
end
|
63
|
-
SpeedGun.discard_profile!
|
64
|
-
end
|
65
|
-
|
66
|
-
def inject_header(headers)
|
67
|
-
headers['X-SpeedGun-Profile-Id'] = SpeedGun.current_profile.id
|
68
|
-
end
|
69
|
-
|
70
|
-
def inject_body(status, headers, body)
|
71
|
-
unless headers['Content-Type'] =~ /text\/html/
|
72
|
-
return [status, headers, body]
|
73
|
-
end
|
74
|
-
|
75
|
-
response = Rack::Response.new([], status, headers)
|
76
|
-
|
77
|
-
body = [body] if body.kind_of?(String)
|
78
|
-
body.each { |fragment| response.write(inject_fragment(fragment)) }
|
79
|
-
body.close if body.respond_to?(:close)
|
80
|
-
|
81
|
-
response.finish
|
82
|
-
end
|
83
|
-
|
84
|
-
def inject_fragment(body)
|
85
|
-
return body unless body.match(BODY_END_REGEXP)
|
86
|
-
|
87
|
-
body.sub(BODY_END_REGEXP) do |matched|
|
88
|
-
SpeedGun::Template.render + matched
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
data/lib/speed_gun/profile.rb
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
require 'securerandom'
|
2
|
-
require 'speed_gun'
|
3
|
-
require 'speed_gun/event'
|
4
|
-
|
5
|
-
class SpeedGun::Profile
|
6
|
-
def self.from_hash(id, hash)
|
7
|
-
profile = new
|
8
|
-
|
9
|
-
hash['events'].map! do |event_id|
|
10
|
-
SpeedGun.config.store.load(SpeedGun::Event, event_id)
|
11
|
-
end
|
12
|
-
|
13
|
-
hash['id'] = id
|
14
|
-
hash.delete('duration')
|
15
|
-
hash.each_pair do |key, val|
|
16
|
-
profile.instance_variable_set(:"@#{key}", val)
|
17
|
-
end
|
18
|
-
|
19
|
-
profile
|
20
|
-
end
|
21
|
-
|
22
|
-
# @return [String] profile ID
|
23
|
-
attr_reader :id
|
24
|
-
|
25
|
-
# @return [Array<SpeedGun::Event>] recorded events
|
26
|
-
attr_reader :events
|
27
|
-
|
28
|
-
# @return [SpeedGun::Config] the config of the profile
|
29
|
-
attr_reader :config
|
30
|
-
|
31
|
-
# @return [Integer] status code of the response
|
32
|
-
attr_accessor :status
|
33
|
-
|
34
|
-
# @return [String] method of the request
|
35
|
-
attr_accessor :request_method
|
36
|
-
|
37
|
-
# @return [String] path of the request
|
38
|
-
attr_accessor :path
|
39
|
-
|
40
|
-
# @return [String] query of the request
|
41
|
-
attr_accessor :query
|
42
|
-
|
43
|
-
# @return [SpeedGun::Profile] instance of SpeedGun::Profile
|
44
|
-
def initialize(config = SpeedGun.config.dup)
|
45
|
-
@id = SecureRandom.uuid
|
46
|
-
@events = []
|
47
|
-
@config = config
|
48
|
-
@active = true
|
49
|
-
end
|
50
|
-
|
51
|
-
# Record an event
|
52
|
-
#
|
53
|
-
# @param event [SpeedGun::Event] record event
|
54
|
-
# @return [Array<SpeedGun::Event>] recorded events
|
55
|
-
def record!(event)
|
56
|
-
config.logger.debug(
|
57
|
-
"[SpeedGun] Record Event: #{event.name}: #{'%0.2f' % (event.duration * 1000)}ms"
|
58
|
-
) if config.logger
|
59
|
-
config.store.save(event) if active?
|
60
|
-
@events.push(event)
|
61
|
-
end
|
62
|
-
|
63
|
-
def active?
|
64
|
-
@active
|
65
|
-
end
|
66
|
-
|
67
|
-
def deactive?
|
68
|
-
!active?
|
69
|
-
end
|
70
|
-
|
71
|
-
def activate!
|
72
|
-
@active = true
|
73
|
-
end
|
74
|
-
|
75
|
-
def deactivate!
|
76
|
-
@active = false
|
77
|
-
end
|
78
|
-
|
79
|
-
def earliest_started_at
|
80
|
-
@events.sort_by(&:started_at).first.started_at
|
81
|
-
end
|
82
|
-
|
83
|
-
def latest_finished_at
|
84
|
-
@events.sort_by { |event| event.finished_at || 0 }.last.finished_at
|
85
|
-
end
|
86
|
-
|
87
|
-
def duration
|
88
|
-
finished_at = latest_finished_at
|
89
|
-
finished_at ? finished_at - earliest_started_at : 0
|
90
|
-
end
|
91
|
-
|
92
|
-
def to_hash
|
93
|
-
{
|
94
|
-
'events' => events.map(&:id),
|
95
|
-
'status' => status,
|
96
|
-
'request_method' => request_method,
|
97
|
-
'path' => path,
|
98
|
-
'query' => query,
|
99
|
-
'duration' => duration
|
100
|
-
}
|
101
|
-
end
|
102
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'speed_gun/store'
|
2
|
-
|
3
|
-
class SpeedGun::Store::ElasticSearchStore < SpeedGun::Store
|
4
|
-
DEFAULT_INDEX = 'speed_gun'
|
5
|
-
|
6
|
-
def initialize(options = {})
|
7
|
-
@index = options[:index] || DEFAULT_INDEX
|
8
|
-
@async = options.fetch(:async, true)
|
9
|
-
@client = options[:client] || default_clinet(options)
|
10
|
-
end
|
11
|
-
|
12
|
-
def save(object)
|
13
|
-
@async ? save_with_async(object) : save_without_async(object)
|
14
|
-
end
|
15
|
-
|
16
|
-
def load(klass, id)
|
17
|
-
hit = @client.search(
|
18
|
-
index: @index,
|
19
|
-
body: {
|
20
|
-
query: {
|
21
|
-
match: {
|
22
|
-
"_id" => id,
|
23
|
-
"_type" => underscore(klass.name)
|
24
|
-
}
|
25
|
-
}
|
26
|
-
}
|
27
|
-
)['hits']['hits'].first['_source']
|
28
|
-
|
29
|
-
klass.from_hash(id, hit)
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def save_with_async(object)
|
35
|
-
Thread.new(object) { |object| save_without_async(object) }
|
36
|
-
end
|
37
|
-
|
38
|
-
def save_without_async(object)
|
39
|
-
@client.index(
|
40
|
-
index: @index,
|
41
|
-
type: underscore(object.class.name),
|
42
|
-
id: object.id,
|
43
|
-
body: object.to_hash.merge(
|
44
|
-
'@timestamp' => Time.now
|
45
|
-
)
|
46
|
-
)
|
47
|
-
end
|
48
|
-
|
49
|
-
def index(klass)
|
50
|
-
[@prefix, underscore(klass.name)].join('-')
|
51
|
-
end
|
52
|
-
|
53
|
-
def underscore(name)
|
54
|
-
name = name
|
55
|
-
name.sub!(/^[A-Z]/) { |c| c.downcase }
|
56
|
-
name.gsub!(/[A-Z]/) { |c| "_#{c.downcase}" }
|
57
|
-
name.gsub!('::', '')
|
58
|
-
end
|
59
|
-
|
60
|
-
def default_clinet(options)
|
61
|
-
require 'elasticsearch' unless defined?(Elasticsearch)
|
62
|
-
Elasticsearch::Client.new(options)
|
63
|
-
end
|
64
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'speed_gun/store'
|
2
|
-
|
3
|
-
class SpeedGun::Store::FluentLoggerStore < SpeedGun::Store
|
4
|
-
DEFAULT_PREFIX = 'speed_gun'
|
5
|
-
|
6
|
-
def initialize(options = {})
|
7
|
-
@prefix = options[:prefix] || DEFAULT_PREFIX
|
8
|
-
@logger = options[:logger] || default_logger(options)
|
9
|
-
end
|
10
|
-
|
11
|
-
def save(object)
|
12
|
-
@logger.post(tag(object), object.to_hash.merge(id: object.id))
|
13
|
-
end
|
14
|
-
|
15
|
-
def load(klass, id)
|
16
|
-
nil
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def tag(object)
|
22
|
-
object.class.name.sub(/.*::/, '').downcase
|
23
|
-
end
|
24
|
-
|
25
|
-
def default_logger(options)
|
26
|
-
require 'fluent-logger' unless defined?(Fluent::Logger)
|
27
|
-
Fluent::Logger::FluentLogger.new(@prefix, options)
|
28
|
-
end
|
29
|
-
end
|