atlas_rb 1.29.8 → 1.29.9
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/.version +1 -1
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +21 -0
- data/lib/atlas_rb/configuration.rb +17 -0
- data/lib/atlas_rb/transport.rb +17 -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: 70d17a2c1a008d2472921d83a239c583c954adf6170747cb20c35411245c3230
|
|
4
|
+
data.tar.gz: 38c3b7541876a8a45288fa3f751c42a5716bad78d76b6374acc868ed7aeae298
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0cca6024196cfba27a06712b51c39b0475e4f6622afeff68defa5173e3ee7a179716e9b058050c4705c9df0b0a363be78c03861dfc28e9b5b9d9b4e3100ae5ba
|
|
7
|
+
data.tar.gz: d239bd7d76883f3c23135a1f63d8bc3b21b94cc5c24e96f584c974f6270036e8169c6e06df0a1a941e891126f3eafac7fa67cd0a7506ffa9f9fbe655afc55bfe
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.29.
|
|
1
|
+
1.29.9
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.29.9
|
|
4
|
+
|
|
5
|
+
### Added — `config.request_id`, sent as `X-Request-Id`
|
|
6
|
+
|
|
7
|
+
A host can set `config.request_id = -> { Current.request_id }`. Every binding
|
|
8
|
+
call then sends that id to Atlas as `X-Request-Id`. Atlas adopts it in place of
|
|
9
|
+
minting its own and tags its log lines with it, so one page view's Atlas
|
|
10
|
+
requests share the host's id. With the slot unset, nothing changes.
|
|
11
|
+
|
|
3
12
|
## 1.29.8
|
|
4
13
|
|
|
5
14
|
### Changed — installs on Ruby 4
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -248,6 +248,27 @@ transport's.
|
|
|
248
248
|
Each attempt emits its own `request.atlas_rb` notification, so a host counting
|
|
249
249
|
round-trips sees a retry as the second round-trip it really is.
|
|
250
250
|
|
|
251
|
+
### Request ids
|
|
252
|
+
|
|
253
|
+
Set `request_id` to send the host's request id to Atlas as `X-Request-Id`:
|
|
254
|
+
|
|
255
|
+
```ruby
|
|
256
|
+
AtlasRb.configure do |config|
|
|
257
|
+
config.request_id = -> { Current.request_id }
|
|
258
|
+
end
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Atlas adopts the id in place of minting its own and tags its log lines with
|
|
262
|
+
it. Every Atlas request that one page view makes then carries the same id the
|
|
263
|
+
host logged, so a single search finds them in both logs.
|
|
264
|
+
|
|
265
|
+
The slot is resolved on each binding call, on the thread that makes it. A host
|
|
266
|
+
that fans reads out on worker threads must copy its request context into each
|
|
267
|
+
worker, or those reads send no id. A blank result sends no header, and Atlas
|
|
268
|
+
mints an id as usual. The health and metrics probes do not send it.
|
|
269
|
+
|
|
270
|
+
The id is a log label only. Atlas trusts nothing about it.
|
|
271
|
+
|
|
251
272
|
## Resource hierarchy
|
|
252
273
|
|
|
253
274
|
```
|
|
@@ -22,6 +22,9 @@ module AtlasRb
|
|
|
22
22
|
# header. Used by the acting-as / view-as feature on the consumer side.
|
|
23
23
|
# `nil` (the default) sends no header.
|
|
24
24
|
#
|
|
25
|
+
# - {#request_id} — the host's request id, sent as `X-Request-Id:` on every
|
|
26
|
+
# binding call so Atlas's log lines carry it.
|
|
27
|
+
#
|
|
25
28
|
# ## Carve-outs
|
|
26
29
|
#
|
|
27
30
|
# System-path calls under {AtlasRb::System} route through
|
|
@@ -149,5 +152,19 @@ module AtlasRb
|
|
|
149
152
|
#
|
|
150
153
|
# @return [Integer, nil]
|
|
151
154
|
attr_accessor :connection_max_requests
|
|
155
|
+
|
|
156
|
+
# The host's own request id, sent to Atlas as `X-Request-Id` on every
|
|
157
|
+
# binding call. Atlas adopts it in place of minting its own and tags its
|
|
158
|
+
# log lines with it, so one page view's Atlas requests can be found by the
|
|
159
|
+
# same id the host logged. Value or callable, resolved per call; typically
|
|
160
|
+
# `-> { Current.request_id }`. `nil` (the default), or a blank result,
|
|
161
|
+
# sends no header and Atlas mints an id as usual.
|
|
162
|
+
#
|
|
163
|
+
# The id is a log label, not a credential: Atlas trusts nothing about it.
|
|
164
|
+
# The health and metrics probes build their own connections and do not
|
|
165
|
+
# send it.
|
|
166
|
+
#
|
|
167
|
+
# @return [String, Proc, nil]
|
|
168
|
+
attr_accessor :request_id
|
|
152
169
|
end
|
|
153
170
|
end
|
data/lib/atlas_rb/transport.rb
CHANGED
|
@@ -91,6 +91,11 @@ module AtlasRb
|
|
|
91
91
|
# header, an `on_data` streaming handler), and those must keep working.
|
|
92
92
|
# The block runs last so a call site can override anything set here.
|
|
93
93
|
class Proxy
|
|
94
|
+
# Atlas adopts an incoming id as its own (Rails' ActionDispatch::RequestId)
|
|
95
|
+
# and tags its log lines with it, so one id names the host's request in
|
|
96
|
+
# both apps' logs.
|
|
97
|
+
REQUEST_ID_HEADER = "X-Request-Id"
|
|
98
|
+
|
|
94
99
|
# Per-request headers and params, exposed so a caller (and the gem's own
|
|
95
100
|
# transport specs) can read what a request will send without making one.
|
|
96
101
|
attr_reader :headers, :params
|
|
@@ -106,7 +111,7 @@ module AtlasRb
|
|
|
106
111
|
# @param params [Hash] per-request query/body params.
|
|
107
112
|
def initialize(connection, headers, params = {})
|
|
108
113
|
@connection = connection
|
|
109
|
-
@headers = headers
|
|
114
|
+
@headers = with_request_id(headers)
|
|
110
115
|
@params = params || {}
|
|
111
116
|
end
|
|
112
117
|
|
|
@@ -141,6 +146,17 @@ module AtlasRb
|
|
|
141
146
|
|
|
142
147
|
private
|
|
143
148
|
|
|
149
|
+
# Resolved here because a proxy is built per binding call, on the thread
|
|
150
|
+
# making it — so a host that copies its request context into worker
|
|
151
|
+
# threads gets the right id on each of them. A caller's own header wins.
|
|
152
|
+
def with_request_id(headers)
|
|
153
|
+
id = AtlasRb.config.request_id
|
|
154
|
+
id = id.call if id.respond_to?(:call)
|
|
155
|
+
return headers if id.nil? || id.to_s.empty? || headers.key?(REQUEST_ID_HEADER)
|
|
156
|
+
|
|
157
|
+
headers.merge(REQUEST_ID_HEADER => id.to_s)
|
|
158
|
+
end
|
|
159
|
+
|
|
144
160
|
def run(method, path, body, headers, params, &block)
|
|
145
161
|
@connection.run_request(method, path, body, headers) do |req|
|
|
146
162
|
req.params.update(@params) unless @params.empty?
|