rails-profiler 0.44.8 → 0.44.10
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/CHANGELOG.md +21 -0
- data/app/controllers/profiler/api/cluster_controller.rb +1 -0
- data/lib/profiler/cluster/master_client.rb +20 -0
- data/lib/profiler/railtie.rb +12 -1
- data/lib/profiler/storage/file_store.rb +2 -2
- data/lib/profiler/storage/private_files.rb +1 -1
- data/lib/profiler/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d65021e93e3235c477b1195389f5baacf516c5d50aa23c4b6ece5d51c70de6c2
|
|
4
|
+
data.tar.gz: 533a3039e716fce5b2326cd543de33ea64294af5a086e2c6419840049fa6bd39
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f96e5eaaf3dd349747120d45777a10a889e94e1eead3ecefcf3beb8178b8010d6889dbc3f212b2f93371abc4a77a62a0fac7427dc4131d055a7d12970ee379e
|
|
7
|
+
data.tar.gz: f6cf807989e0e7eb87e2ec99723f17e79e94595d5be951c30f6c1fad2db0ef0aff5c8abc8ab99ffac69acd7840c2aa7f42b10510d99147c49daed0770d6fb616
|
data/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,27 @@ every commit of every tag interval is accounted for one way or the other.
|
|
|
19
19
|
|
|
20
20
|
## [Unreleased]
|
|
21
21
|
|
|
22
|
+
## [0.44.10] - 2026-10-22
|
|
23
|
+
|
|
24
|
+
<!-- stamped -->
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **Cluster:** the master now logs a warning when a process with `cluster_master=true` forks, and
|
|
29
|
+
when a heartbeat is received for a slave not seen in the current worker, to help detect the
|
|
30
|
+
misconfiguration of running multiple master workers without a shared registry.
|
|
31
|
+
- **Documentation:** `DECISIONS.md` now correctly states that the gem provides shared storage
|
|
32
|
+
backends (file, SQLite, Redis); the decision to keep the slave registry single-process is based
|
|
33
|
+
on avoiding per-heartbeat writes, not on the lack of storage options.
|
|
34
|
+
|
|
35
|
+
## [0.44.9] - 2026-10-22
|
|
36
|
+
|
|
37
|
+
<!-- stamped -->
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
|
|
41
|
+
- **File storage:** profile paths containing non-ASCII characters (e.g., `/café`) are now correctly saved and loaded even when the system's default encoding is not UTF-8 (e.g., `LANG=C`).
|
|
42
|
+
|
|
22
43
|
## [0.44.8] - 2026-10-22
|
|
23
44
|
|
|
24
45
|
<!-- stamped -->
|
|
@@ -27,6 +27,7 @@ module Profiler
|
|
|
27
27
|
name = params[:name].to_s
|
|
28
28
|
entry = Profiler.slave_registry.heartbeat(name)
|
|
29
29
|
if entry.nil?
|
|
30
|
+
Profiler.log_warn("Cluster: received heartbeat for unknown slave #{name.inspect} (possible multi-worker misconfiguration)")
|
|
30
31
|
render json: { error: "Unknown slave - please re-register" }, status: :not_found
|
|
31
32
|
else
|
|
32
33
|
render json: { ok: true }
|
|
@@ -20,6 +20,15 @@ module Profiler
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
# Fork hook for a pure master (cluster_master=true, not a slave): logs a warning when forking.
|
|
24
|
+
module PureMasterForkHook
|
|
25
|
+
def _fork
|
|
26
|
+
pid = super
|
|
27
|
+
Profiler.log_warn("Cluster: master process forked: each worker maintains a separate slave registry") if pid.zero?
|
|
28
|
+
pid
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
23
32
|
# A master that does not answer must cost the heartbeat thread a few seconds, not a minute.
|
|
24
33
|
OPEN_TIMEOUT = 3
|
|
25
34
|
READ_TIMEOUT = 5
|
|
@@ -35,6 +44,13 @@ module Profiler
|
|
|
35
44
|
@fork_hook_installed = true
|
|
36
45
|
end
|
|
37
46
|
|
|
47
|
+
def install_pure_master_fork_hook!
|
|
48
|
+
return false if @pure_master_fork_hook_installed || !Process.respond_to?(:_fork)
|
|
49
|
+
|
|
50
|
+
Process.singleton_class.prepend(PureMasterForkHook)
|
|
51
|
+
@pure_master_fork_hook_installed = true
|
|
52
|
+
end
|
|
53
|
+
|
|
38
54
|
def restart_after_fork
|
|
39
55
|
current&.restart_after_fork
|
|
40
56
|
rescue => e
|
|
@@ -57,6 +73,10 @@ module Profiler
|
|
|
57
73
|
def restart_after_fork
|
|
58
74
|
return if @started.nil? || @thread&.alive?
|
|
59
75
|
|
|
76
|
+
if Profiler.configuration.cluster_master?
|
|
77
|
+
log_warn("master process forked: each worker maintains a separate slave registry")
|
|
78
|
+
end
|
|
79
|
+
|
|
60
80
|
@registered = false
|
|
61
81
|
@failed = false
|
|
62
82
|
start_heartbeat_thread
|
data/lib/profiler/railtie.rb
CHANGED
|
@@ -133,9 +133,20 @@ module Profiler
|
|
|
133
133
|
Profiler::Cluster::Security.warn_about_configuration(Rails.logger)
|
|
134
134
|
require_relative "peers"
|
|
135
135
|
Profiler::Peers.warn_about_configuration(Rails.logger)
|
|
136
|
-
next unless Profiler.configuration.slave?
|
|
137
136
|
|
|
138
137
|
require_relative "cluster/master_client"
|
|
138
|
+
|
|
139
|
+
cluster_master = Profiler.configuration.cluster_master?
|
|
140
|
+
is_slave = Profiler.configuration.slave?
|
|
141
|
+
|
|
142
|
+
# Install fork hook for pure masters (cluster_master=true, not a slave).
|
|
143
|
+
# If also a slave, MasterClient.start will install the fork hook and handle warnings.
|
|
144
|
+
if cluster_master && !is_slave
|
|
145
|
+
Profiler::Cluster::MasterClient.install_pure_master_fork_hook!
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
next unless is_slave
|
|
149
|
+
|
|
139
150
|
Profiler::Cluster::MasterClient.new.start
|
|
140
151
|
end
|
|
141
152
|
end
|
|
@@ -97,7 +97,7 @@ module Profiler
|
|
|
97
97
|
file_path = profile_file_path(token)
|
|
98
98
|
return nil unless File.exist?(file_path)
|
|
99
99
|
|
|
100
|
-
json_data = File.read(file_path)
|
|
100
|
+
json_data = File.read(file_path, encoding: Encoding::UTF_8)
|
|
101
101
|
Models::Profile.from_json(json_data)
|
|
102
102
|
rescue StandardError => e
|
|
103
103
|
Profiler.log_error("FileStore: could not load profile #{token}", e)
|
|
@@ -240,7 +240,7 @@ module Profiler
|
|
|
240
240
|
|
|
241
241
|
record = JSON.parse(line)
|
|
242
242
|
record.is_a?(Hash) ? record : nil
|
|
243
|
-
rescue JSON::ParserError
|
|
243
|
+
rescue JSON::ParserError, EncodingError
|
|
244
244
|
nil
|
|
245
245
|
end
|
|
246
246
|
|
|
@@ -80,7 +80,7 @@ module Profiler
|
|
|
80
80
|
|
|
81
81
|
# Opens path for reading, refusing a symbolic link while the modes are restricted.
|
|
82
82
|
def open_for_reading(path, &block)
|
|
83
|
-
File.open(path.to_s, File::RDONLY | nofollow, &block)
|
|
83
|
+
File.open(path.to_s, File::RDONLY | nofollow, encoding: Encoding::UTF_8, &block)
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
# Opens path for reading and writing, creating it 0600 when missing.
|
data/lib/profiler/version.rb
CHANGED