atlas_rb 1.29.7 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 966b7b990c4e511a304cc00ff85d927c2480912b19cc242ea83bb9d0cf153a00
4
- data.tar.gz: e1842a0db3d17034b5c9520e9ffc86a5aa1a22c446b233a8e3cb90cce054394e
3
+ metadata.gz: 70d17a2c1a008d2472921d83a239c583c954adf6170747cb20c35411245c3230
4
+ data.tar.gz: 38c3b7541876a8a45288fa3f751c42a5716bad78d76b6374acc868ed7aeae298
5
5
  SHA512:
6
- metadata.gz: 5d7768219f0487961b9516f0d7b892ee8fb977c8fc84e704163237534a8e1b3324f1379000e9bfc5d0203d0a9bae1c0d512875d1404e5dff41625506224a29f7
7
- data.tar.gz: 9c69d4d9423397750596333cf8d990fae3e2b5ea895a799d79b94e23878c2a01ac77d58c12a24ead1d621b5caeee3a1aed7e6491d8c2586389cd339539aee18a
6
+ metadata.gz: 0cca6024196cfba27a06712b51c39b0475e4f6622afeff68defa5173e3ee7a179716e9b058050c4705c9df0b0a363be78c03861dfc28e9b5b9d9b4e3100ae5ba
7
+ data.tar.gz: d239bd7d76883f3c23135a1f63d8bc3b21b94cc5c24e96f584c974f6270036e8169c6e06df0a1a941e891126f3eafac7fa67cd0a7506ffa9f9fbe655afc55bfe
data/.rubocop.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  AllCops:
2
2
  NewCops: enable
3
- TargetRubyVersion: 2.6
3
+ TargetRubyVersion: 3.2
4
4
 
5
5
  Style/StringLiterals:
6
6
  Enabled: true
data/.version CHANGED
@@ -1 +1 @@
1
- 1.29.7
1
+ 1.29.9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
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
+
12
+ ## 1.29.8
13
+
14
+ ### Changed — installs on Ruby 4
15
+
16
+ The `faraday-follow_redirects` dependency is now `~> 0.5`. Every release
17
+ before 0.5.0 declared `required_ruby_version < 4`, so no app that depended
18
+ on atlas_rb could bundle on Ruby 4. Release 0.5.0 drops that cap and
19
+ changes no behaviour. The gem's own Ruby floor stays at 3.2.
20
+
3
21
  ## 1.29.7
4
22
 
5
23
  Needs Atlas 0.6.282 or later. An older Atlas still puts the rows under
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- atlas_rb (1.29.7)
4
+ atlas_rb (1.29.9)
5
5
  faraday (~> 2.7)
6
- faraday-follow_redirects (~> 0.3.0)
6
+ faraday-follow_redirects (~> 0.5)
7
7
  faraday-multipart (~> 1)
8
8
  faraday-net_http_persistent (~> 2.3)
9
9
  faraday-retry (~> 2.4)
@@ -20,7 +20,7 @@ GEM
20
20
  faraday-net_http (>= 2.0, < 3.6)
21
21
  json
22
22
  logger
23
- faraday-follow_redirects (0.3.0)
23
+ faraday-follow_redirects (0.5.0)
24
24
  faraday (>= 1, < 3)
25
25
  faraday-multipart (1.2.0)
26
26
  multipart-post (~> 2.0)
@@ -69,8 +69,8 @@ PLATFORMS
69
69
  DEPENDENCIES
70
70
  atlas_rb!
71
71
  rake (~> 13.0)
72
- rspec (~> 3.0)
72
+ rspec (~> 3.12, ~> 3.0)
73
73
  yard (~> 0.9)
74
74
 
75
75
  BUNDLED WITH
76
- 2.2.33
76
+ 4.0.20
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
@@ -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?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atlas_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.29.7
4
+ version: 1.29.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cliff
@@ -57,14 +57,14 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 0.3.0
60
+ version: '0.5'
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: 0.3.0
67
+ version: '0.5'
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: faraday-retry
70
70
  requirement: !ruby/object:Gem::Requirement
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  - !ruby/object:Gem::Version
209
209
  version: '0'
210
210
  requirements: []
211
- rubygems_version: 3.6.9
211
+ rubygems_version: 4.0.20
212
212
  specification_version: 4
213
213
  summary: Ruby gem for Atlas API.
214
214
  test_files: []