app_profiler 0.1.6 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/app_profiler/railtie.rb +3 -0
- data/lib/app_profiler/server.rb +3 -1
- data/lib/app_profiler/storage/google_cloud_storage.rb +10 -1
- data/lib/app_profiler/version.rb +1 -1
- data/lib/app_profiler.rb +27 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a4f543410317515564af0f46a5f437e33af8a7c66334e6cfd42830e37dfb89c
|
4
|
+
data.tar.gz: bb37127c11ae94eade6d736d14d3609e7e99854709659dd9b7bb081e8cbb86b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a6da942b841feddb9b78d8a212b4c546b89e4966130419c87ad167f5c698301753fa4c14c4a6548338b341b217fed8418a71e9ceb2dc3a9289211436c036bd8
|
7
|
+
data.tar.gz: bdb22060ba83526a177c34302e731960d4eff6c563efe313f19e8282535632fa61c71ba269ce90700066166b6102244b1b1cdf6463b97d877fc45deb27828127
|
data/lib/app_profiler/railtie.rb
CHANGED
@@ -37,6 +37,9 @@ module AppProfiler
|
|
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
39
|
AppProfiler.profile_file_prefix = app.config.app_profiler.profile_file_prefix || DefaultProfilePrefix
|
40
|
+
AppProfiler.profile_enqueue_success = app.config.app_profiler.profile_enqueue_success
|
41
|
+
AppProfiler.profile_enqueue_failure = app.config.app_profiler.profile_enqueue_failure
|
42
|
+
AppProfiler.after_process_queue = app.config.app_profiler.after_process_queue
|
40
43
|
end
|
41
44
|
|
42
45
|
initializer "app_profiler.add_middleware" do |app|
|
data/lib/app_profiler/server.rb
CHANGED
@@ -225,8 +225,10 @@ module AppProfiler
|
|
225
225
|
end
|
226
226
|
|
227
227
|
def stop
|
228
|
-
File.unlink(@socket_file) if File.exist?(@socket_file) && File.socket?(@socket_file)
|
229
228
|
@socket.close
|
229
|
+
File.unlink(@socket_file) if File.exist?(@socket_file) && File.socket?(@socket_file)
|
230
|
+
ObjectSpace.undefine_finalizer(self)
|
231
|
+
nil
|
230
232
|
end
|
231
233
|
|
232
234
|
def abandon
|
@@ -25,6 +25,8 @@ module AppProfiler
|
|
25
25
|
content_type: "application/json",
|
26
26
|
content_encoding: "gzip",
|
27
27
|
)
|
28
|
+
ensure
|
29
|
+
profile.file.unlink
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
@@ -35,8 +37,10 @@ module AppProfiler
|
|
35
37
|
@queue ||= init_queue
|
36
38
|
begin
|
37
39
|
@queue.push(profile, true) # non-blocking push, raises ThreadError if queue is full
|
40
|
+
AppProfiler.profile_enqueue_success&.call
|
38
41
|
rescue ThreadError
|
39
42
|
AppProfiler.logger.info("[AppProfiler] upload queue is full, profile discarded")
|
43
|
+
AppProfiler.profile_enqueue_failure&.call(profile)
|
40
44
|
end
|
41
45
|
end
|
42
46
|
end
|
@@ -78,7 +82,12 @@ module AppProfiler
|
|
78
82
|
|
79
83
|
return unless queue
|
80
84
|
|
81
|
-
|
85
|
+
num_success = 0
|
86
|
+
num_failures = 0
|
87
|
+
queue.size.times do
|
88
|
+
queue.pop(false).upload ? num_success += 1 : num_failures += 1
|
89
|
+
end
|
90
|
+
AppProfiler.after_process_queue&.call(num_success, num_failures)
|
82
91
|
end
|
83
92
|
|
84
93
|
def gcs_filename(profile)
|
data/lib/app_profiler/version.rb
CHANGED
data/lib/app_profiler.rb
CHANGED
@@ -55,6 +55,9 @@ module AppProfiler
|
|
55
55
|
mattr_accessor :upload_queue_max_length, default: 10
|
56
56
|
mattr_accessor :upload_queue_interval_secs, default: 5
|
57
57
|
mattr_accessor :profile_file_prefix, default: DefaultProfilePrefix
|
58
|
+
mattr_reader :profile_enqueue_success, default: nil
|
59
|
+
mattr_reader :profile_enqueue_failure, default: nil
|
60
|
+
mattr_reader :after_process_queue, default: nil
|
58
61
|
|
59
62
|
class << self
|
60
63
|
def run(*args, &block)
|
@@ -88,6 +91,30 @@ module AppProfiler
|
|
88
91
|
@@profile_url_formatter = block # rubocop:disable Style/ClassVars
|
89
92
|
end
|
90
93
|
|
94
|
+
def profile_enqueue_success=(handler)
|
95
|
+
if handler && (!handler.is_a?(Proc) || (handler.lambda? && handler.arity != 0))
|
96
|
+
raise ArgumentError, "profile_enqueue_success must be proc or a lambda that accepts no argument"
|
97
|
+
end
|
98
|
+
|
99
|
+
@@profile_enqueue_success = handler # rubocop:disable Style/ClassVars
|
100
|
+
end
|
101
|
+
|
102
|
+
def profile_enqueue_failure=(handler)
|
103
|
+
if handler && (!handler.is_a?(Proc) || (handler.lambda? && handler.arity != 1))
|
104
|
+
raise ArgumentError, "profile_enqueue_failure must be a proc or a lambda that accepts one argument"
|
105
|
+
end
|
106
|
+
|
107
|
+
@@profile_enqueue_failure = handler # rubocop:disable Style/ClassVars
|
108
|
+
end
|
109
|
+
|
110
|
+
def after_process_queue=(handler)
|
111
|
+
if handler && (!handler.is_a?(Proc) || (handler.lambda? && handler.arity != 2))
|
112
|
+
raise ArgumentError, "after_process_queue must be a proc or a lambda that accepts two arguments"
|
113
|
+
end
|
114
|
+
|
115
|
+
@@after_process_queue = handler # rubocop:disable Style/ClassVars
|
116
|
+
end
|
117
|
+
|
91
118
|
def profile_url(upload)
|
92
119
|
return unless AppProfiler.profile_url_formatter
|
93
120
|
|
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.8
|
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-11-06 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: activesupport
|