app_profiler 0.1.4 → 0.1.6
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/lib/app_profiler/middleware/upload_action.rb +1 -1
- data/lib/app_profiler/profile.rb +1 -1
- data/lib/app_profiler/railtie.rb +1 -0
- data/lib/app_profiler/server.rb +37 -5
- data/lib/app_profiler/version.rb +1 -1
- data/lib/app_profiler.rb +5 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 443e88eecba7bccc081c2b44d2a0840570c54793025251e960242bd76dc86090
|
4
|
+
data.tar.gz: fcc47ff7544b73faa76160212b1ef0134b2f7239de758ec8af86887abe41ef59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fda25b4c3e449d7f8c35341649c96679e299dbc3110e44911dcd1e970bce64b0abf2aaf3fe4830ba729fdac3780477ff626b6451579a74bdd2ceac6cf9c866b
|
7
|
+
data.tar.gz: 3f5020c4c4a5c817c4692a622001fa7ad851316b20cfdb0ad0057a04ab2e0d6736d1dae17e397d5a7d6aa9b2eab464c1dc39f3e0e653dc46530e96ec7eaf86c6
|
@@ -7,7 +7,7 @@ module AppProfiler
|
|
7
7
|
def call(profile, response: nil, autoredirect: nil, async: false)
|
8
8
|
if async
|
9
9
|
profile.enqueue_upload
|
10
|
-
response[1][AppProfiler.profile_async_header] = true
|
10
|
+
response[1][AppProfiler.profile_async_header] = "true"
|
11
11
|
else
|
12
12
|
profile_upload = profile.upload
|
13
13
|
|
data/lib/app_profiler/profile.rb
CHANGED
data/lib/app_profiler/railtie.rb
CHANGED
@@ -36,6 +36,7 @@ module AppProfiler
|
|
36
36
|
AppProfiler.profile_url_formatter = app.config.app_profiler.profile_url_formatter
|
37
37
|
AppProfiler.upload_queue_max_length = app.config.app_profiler.upload_queue_max_length || 10
|
38
38
|
AppProfiler.upload_queue_interval_secs = app.config.app_profiler.upload_queue_interval_secs || 5
|
39
|
+
AppProfiler.profile_file_prefix = app.config.app_profiler.profile_file_prefix || DefaultProfilePrefix
|
39
40
|
end
|
40
41
|
|
41
42
|
initializer "app_profiler.add_middleware" do |app|
|
data/lib/app_profiler/server.rb
CHANGED
@@ -198,11 +198,26 @@ module AppProfiler
|
|
198
198
|
end
|
199
199
|
|
200
200
|
class UNIX < Transport
|
201
|
+
class << self
|
202
|
+
def unlink_socket(path, pid)
|
203
|
+
->(_) do
|
204
|
+
if Process.pid == pid && File.exist?(path)
|
205
|
+
begin
|
206
|
+
File.unlink(path)
|
207
|
+
rescue SystemCallError
|
208
|
+
# Let not raise in a finalizer
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
201
215
|
def start
|
202
216
|
FileUtils.mkdir_p(PROFILER_TEMPFILE_PATH)
|
203
217
|
@socket_file = File.join(PROFILER_TEMPFILE_PATH, "app-profiler-#{Process.pid}.sock")
|
204
218
|
File.unlink(@socket_file) if File.exist?(@socket_file) && File.socket?(@socket_file)
|
205
219
|
@socket = UNIXServer.new(@socket_file)
|
220
|
+
ObjectSpace.define_finalizer(self, self.class.unlink_socket(@socket_file, Process.pid))
|
206
221
|
end
|
207
222
|
|
208
223
|
def client
|
@@ -213,6 +228,10 @@ module AppProfiler
|
|
213
228
|
File.unlink(@socket_file) if File.exist?(@socket_file) && File.socket?(@socket_file)
|
214
229
|
@socket.close
|
215
230
|
end
|
231
|
+
|
232
|
+
def abandon
|
233
|
+
@socket.close
|
234
|
+
end
|
216
235
|
end
|
217
236
|
|
218
237
|
class TCP < Transport
|
@@ -238,6 +257,11 @@ module AppProfiler
|
|
238
257
|
@port_file.unlink
|
239
258
|
@socket.close
|
240
259
|
end
|
260
|
+
|
261
|
+
def abandon
|
262
|
+
@port_file.close # NB: Tempfile finalizer checks Process.pid to avoid unlinking inherited IOs.
|
263
|
+
@socket.close
|
264
|
+
end
|
241
265
|
end
|
242
266
|
|
243
267
|
def initialize(transport, logger)
|
@@ -257,13 +281,16 @@ module AppProfiler
|
|
257
281
|
"[AppProfiler::Server] listening on addr=#{@transport.socket.addr}"
|
258
282
|
)
|
259
283
|
@pid = Process.pid
|
260
|
-
at_exit { stop }
|
261
284
|
end
|
262
285
|
|
263
286
|
def client
|
264
287
|
@transport.client
|
265
288
|
end
|
266
289
|
|
290
|
+
def join(...)
|
291
|
+
@listen_thread.join(...)
|
292
|
+
end
|
293
|
+
|
267
294
|
def serve
|
268
295
|
return unless @listen_thread.nil?
|
269
296
|
|
@@ -324,10 +351,12 @@ module AppProfiler
|
|
324
351
|
end
|
325
352
|
|
326
353
|
def stop
|
327
|
-
return unless @pid == Process.pid
|
328
|
-
|
329
354
|
@listen_thread.kill
|
330
|
-
@
|
355
|
+
if @pid == Process.pid
|
356
|
+
@transport.stop
|
357
|
+
else
|
358
|
+
@transport.abandon
|
359
|
+
end
|
331
360
|
end
|
332
361
|
end
|
333
362
|
|
@@ -371,7 +400,10 @@ module AppProfiler
|
|
371
400
|
private
|
372
401
|
|
373
402
|
def profile_server
|
374
|
-
|
403
|
+
if @pid != Process.pid
|
404
|
+
@profile_server&.stop
|
405
|
+
@profile_server = nil
|
406
|
+
end
|
375
407
|
@profile_server
|
376
408
|
end
|
377
409
|
|
data/lib/app_profiler/version.rb
CHANGED
data/lib/app_profiler.rb
CHANGED
@@ -13,6 +13,10 @@ module AppProfiler
|
|
13
13
|
"#{AppProfiler.speedscope_host}#profileURL=#{upload.url}"
|
14
14
|
end
|
15
15
|
|
16
|
+
DefaultProfilePrefix = proc do
|
17
|
+
Time.zone.now.strftime("%Y%m%d-%H%M%S")
|
18
|
+
end
|
19
|
+
|
16
20
|
module Storage
|
17
21
|
autoload :BaseStorage, "app_profiler/storage/base_storage"
|
18
22
|
autoload :FileStorage, "app_profiler/storage/file_storage"
|
@@ -50,6 +54,7 @@ module AppProfiler
|
|
50
54
|
mattr_accessor :server, default: Server
|
51
55
|
mattr_accessor :upload_queue_max_length, default: 10
|
52
56
|
mattr_accessor :upload_queue_interval_secs, default: 5
|
57
|
+
mattr_accessor :profile_file_prefix, default: DefaultProfilePrefix
|
53
58
|
|
54
59
|
class << self
|
55
60
|
def run(*args, &block)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app_profiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gannon McGibbon
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2023-
|
16
|
+
date: 2023-10-18 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: activesupport
|
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
- !ruby/object:Gem::Version
|
176
176
|
version: '0'
|
177
177
|
requirements: []
|
178
|
-
rubygems_version: 3.4.
|
178
|
+
rubygems_version: 3.4.21
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: Collect performance profiles for your Rails application.
|