railwatch 0.3.1 → 0.3.2
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 +20 -0
- data/lib/railwatch/engine.rb +9 -0
- data/lib/railwatch/reporter.rb +26 -0
- data/lib/railwatch/version.rb +1 -1
- data/lib/railwatch.rb +15 -0
- 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: a2929e5724d581361c5ce2e20a4184dcde4ad190edca068527a5f565043c5a9c
|
|
4
|
+
data.tar.gz: e63ea3bc8d89318bc4e296d17c006eb87dfb3ea06be0db5dea4dea6035a0dfc5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b9477f54a79df466ad5113b56d7206cc7da3d6dd76db86e30c568bc6a9e6378a6545d2a3013fae33d6cef2ffd4d986fd18e9b07051ba67429a52fe38bb33fdee
|
|
7
|
+
data.tar.gz: '0892577170dc73fcd351ce620da0908afd9d2bd4b78f672e2931efb7130eacde83219664cd8d6afac36416d97c691d4897ab2355e6ff5c3f976ec3b4e73ac80b'
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.2 (2026-09-19)
|
|
4
|
+
|
|
5
|
+
- Fix an embedded install's rake tasks reporting over HTTP instead of into
|
|
6
|
+
the app's own database. A rake process invokes its top-level task -- where
|
|
7
|
+
the command patch starts the execution, and sampling it builds the
|
|
8
|
+
reporter -- before that task's `:environment` prerequisite boots Rails and
|
|
9
|
+
runs `config/initializers`. A token in the environment is enough for
|
|
10
|
+
Railwatch to be enabled that early, so the reporter chose HTTP from a
|
|
11
|
+
config that had not yet been told the app is embedded, and kept it.
|
|
12
|
+
Every rake task's telemetry then went to the receiver instead of the
|
|
13
|
+
local database, skipping the export queue and the replay receipt it
|
|
14
|
+
earns. Affects embedded and hybrid installs with a token configured;
|
|
15
|
+
cloud-only installs were never affected, and neither was an embedded
|
|
16
|
+
install with no token.
|
|
17
|
+
- The reporter now re-decides what it derived from a not-yet-final config
|
|
18
|
+
once `config/initializers` has run: its transport, and its buffer size
|
|
19
|
+
while that buffer is still empty.
|
|
20
|
+
- Add a subprocess regression that reproduces rake's ordering and fails if
|
|
21
|
+
an embedded app's rake task reports over HTTP.
|
|
22
|
+
|
|
3
23
|
## 0.3.1 (2026-09-19)
|
|
4
24
|
|
|
5
25
|
- Fix production boot for cloud-only installs with no Railwatch databases.
|
data/lib/railwatch/engine.rb
CHANGED
|
@@ -112,6 +112,15 @@ module Railwatch
|
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
114
|
|
|
115
|
+
# A rake process starts its command execution before this point -- the
|
|
116
|
+
# top-level task is invoked before its `:environment` prerequisite boots
|
|
117
|
+
# Rails -- so a reporter can already exist, built from a config that had
|
|
118
|
+
# not yet been told the app is embedded. This is the first moment the
|
|
119
|
+
# app's own configuration is final.
|
|
120
|
+
initializer "railwatch.adopt_final_config", after: :load_config_initializers do
|
|
121
|
+
Railwatch.adopt_final_config!
|
|
122
|
+
end
|
|
123
|
+
|
|
115
124
|
initializer "railwatch.transport_security", after: :load_config_initializers do
|
|
116
125
|
next if Railwatch.config.local? || Railwatch.config.ingest_url_allowed?
|
|
117
126
|
|
data/lib/railwatch/reporter.rb
CHANGED
|
@@ -143,6 +143,32 @@ module Railwatch
|
|
|
143
143
|
self
|
|
144
144
|
end
|
|
145
145
|
|
|
146
|
+
# The reporter can be built before the application's own configuration
|
|
147
|
+
# has had its say. A rake process invokes its top-level task -- which is
|
|
148
|
+
# where the command patch starts the execution, and sampling that
|
|
149
|
+
# execution builds the reporter -- before the task's `:environment`
|
|
150
|
+
# prerequisite boots Rails and runs config/initializers. A token in the
|
|
151
|
+
# environment is enough for Railwatch to be enabled that early, so an
|
|
152
|
+
# embedded app gets a reporter aimed at HTTP, chosen from a config that
|
|
153
|
+
# had not yet been told the app is embedded. Left alone it stays aimed
|
|
154
|
+
# there: the memo outlives the configuration that produced it, and every
|
|
155
|
+
# record from that process goes to the receiver instead of the app's own
|
|
156
|
+
# database, skipping the export queue and the replay receipts it earns.
|
|
157
|
+
#
|
|
158
|
+
# Nothing has been recorded at that point -- starting an execution
|
|
159
|
+
# decides sampling and pushes nothing -- so deciding again here is free.
|
|
160
|
+
def adopt_final_config!
|
|
161
|
+
# The swap forked_transport already makes, for the same reason: the
|
|
162
|
+
# situation this transport was chosen for is not the situation now.
|
|
163
|
+
reselected = Railwatch.local_transport if @config.local?
|
|
164
|
+
@transport = reselected if reselected && reselected.class != @transport.class
|
|
165
|
+
# Sized from the config as it stood, which was the default one. Safe
|
|
166
|
+
# only while the buffer is still empty: resizing means a new buffer,
|
|
167
|
+
# and anything already in the old one would go with it.
|
|
168
|
+
@buffer = build_buffer if @thread.nil? && @buffer.size.zero?
|
|
169
|
+
self
|
|
170
|
+
end
|
|
171
|
+
|
|
146
172
|
def shutdown
|
|
147
173
|
ensure_process!
|
|
148
174
|
ensure_thread if pending_records? && !@thread&.alive?
|
data/lib/railwatch/version.rb
CHANGED
data/lib/railwatch.rb
CHANGED
|
@@ -72,6 +72,21 @@ module Railwatch
|
|
|
72
72
|
@reporter ||= Reporter.new(config, transport: local_transport)
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
+
# Called once config/initializers has run, so a reporter built before
|
|
76
|
+
# that can re-decide what it derived from a configuration that was not
|
|
77
|
+
# final. Deliberately does not build one: a process that has not
|
|
78
|
+
# reported anything yet has nothing to correct, and the reporter is
|
|
79
|
+
# built on first use for a reason.
|
|
80
|
+
def adopt_final_config!
|
|
81
|
+
# The redactor snapshots redact_headers when it is built. Today nothing
|
|
82
|
+
# redacts before this point, so it is built later and already correct --
|
|
83
|
+
# but an early one would quietly stop hiding the headers an app asked it
|
|
84
|
+
# to hide, which is not a failure worth leaving to ordering. Dropping the
|
|
85
|
+
# memo costs a rebuild on next use and nothing else; it holds only caches.
|
|
86
|
+
@redactor = nil
|
|
87
|
+
@reporter&.adopt_final_config!
|
|
88
|
+
end
|
|
89
|
+
|
|
75
90
|
# Embedded mode: a Puma worker hands its batches to the writer process
|
|
76
91
|
# over the socket; the writer itself, and any process when no socket is
|
|
77
92
|
# configured, writes them straight into SQLite. nil means HTTP.
|