atlas_rb 1.8.9 → 1.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1fd50831467b065989eb0ec39af5f96b87622c5d0e161e0e6a5bdef61764505a
4
- data.tar.gz: 55c36e14086a0fab3776771c797af98c9a431cca3f0b09f14ffac478ab58067c
3
+ metadata.gz: 2a1ca62f7d0e0d49e63754618a22967d8a89a4496c05c894bbbff7f13903e94d
4
+ data.tar.gz: 5645596297711e7cc464645d249b91b4b62108eaf71978f9d07ffed9590043cd
5
5
  SHA512:
6
- metadata.gz: 7aea8252388df4686a31174ca154b7e76da1d97dd16a8509f773bd2b918dfb282ccb93960f5138b0581df9d32d20c45a0f8cf4a1475dda787468644e1d83cdbd
7
- data.tar.gz: 25e3ecf9a7cc353645a8a1ad76700523bba185895fcf1df13b9b098549a45287fb3a9c41abb0eefa559f5e1d8b4c8c4b81b7c16e5e418f4cee39e5f0d554dc56
6
+ metadata.gz: acd99d449e3dd94bb23cfdeabfc1190d2a074e5bfe07a2a4a8e54723fad47680f525d52e761f5ccee50ac1b464a39b889331e6468fe63bb9a0b06f8d17526262
7
+ data.tar.gz: c2d0db210a2a66cb41bc68baec3b6158916a86866c9a20182efc1bc2240f26e0c00357e340d08b4313312e239fabc9338bbca3f6face3c9d0576ef13d9f1f74d
data/.version CHANGED
@@ -1 +1 @@
1
- 1.8.9
1
+ 1.8.10
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- atlas_rb (1.8.9)
4
+ atlas_rb (1.8.10)
5
5
  faraday (~> 2.7)
6
6
  faraday-follow_redirects (~> 0.3.0)
7
7
  faraday-multipart (~> 1)
@@ -36,9 +36,28 @@ module AtlasRb
36
36
  # If neither a signing key nor `ATLAS_JWT` is configured there is no relay
37
37
  # credential, so the transport raises {AtlasRb::ConfigurationError}.
38
38
  #
39
+ # ## Instrumentation
40
+ #
41
+ # Every builder brackets its request in an `ActiveSupport::Notifications`
42
+ # event named **`request.atlas_rb`** (Faraday's `:instrumentation`
43
+ # middleware, wired as the *outermost* handler so a redirect hop — e.g. the
44
+ # `/resources/:noid` NOID resolver — folds into one event per logical call
45
+ # rather than being double-counted). The payload is the Faraday `env`, so a
46
+ # subscriber reads `payload.method` / `payload.url` and the event's duration.
47
+ # This lets a host count/time Atlas round-trips (an N+1-over-HTTP detector)
48
+ # without reaching into gem internals. It is guarded on
49
+ # `defined?(ActiveSupport::Notifications)`: Rails hosts get the events; the
50
+ # headless BYO-JWT path (no AS loaded) is unaffected. With no subscriber
51
+ # attached the emit degrades to a listener lookup + `yield`, so it is safe to
52
+ # leave in the stack permanently — opt-in lives entirely on the consumer side.
53
+ #
39
54
  # The module is mixed in via `extend`, so its methods become class methods on
40
55
  # the host (e.g. `AtlasRb::Work.connection({})`).
41
56
  module FaradayHelper
57
+ # ActiveSupport::Notifications event name emitted per outbound Atlas request.
58
+ # A dedicated name (not Faraday's default `request.faraday`) so a host that
59
+ # also uses Faraday for other clients can subscribe to Atlas traffic alone.
60
+ INSTRUMENTATION_EVENT = "request.atlas_rb"
42
61
  # Wire contract Atlas enforces for relay-signing assertions (see Atlas
43
62
  # ApplicationController#verify_cerberus_assertion). iss/aud are fixed; the
44
63
  # short TTL bounds replay (Atlas allows 30s leeway on exp).
@@ -83,6 +102,7 @@ module AtlasRb
83
102
  params: params,
84
103
  headers: headers
85
104
  ) do |f|
105
+ instrument(f)
86
106
  f.use AtlasRb::Middleware::RaiseOnStaleResource
87
107
  f.use AtlasRb::Middleware::RaiseOnResourceError
88
108
  f.response :follow_redirects
@@ -123,6 +143,7 @@ module AtlasRb
123
143
  url: ENV.fetch("ATLAS_URL", nil),
124
144
  headers: headers
125
145
  ) do |f|
146
+ instrument(f)
126
147
  f.use AtlasRb::Middleware::RaiseOnStaleResource
127
148
  # Translate Atlas's verify-on-ingest 422 (fixity_mismatch /
128
149
  # unsupported_digest_algorithm) into a typed FixityMismatchError —
@@ -190,6 +211,7 @@ module AtlasRb
190
211
  params: params,
191
212
  headers: headers
192
213
  ) do |f|
214
+ instrument(f)
193
215
  f.response :follow_redirects
194
216
  f.adapter Faraday.default_adapter
195
217
  end
@@ -197,6 +219,20 @@ module AtlasRb
197
219
 
198
220
  private
199
221
 
222
+ # Register Faraday's instrumentation middleware as the OUTERMOST handler so
223
+ # each logical call emits exactly one {INSTRUMENTATION_EVENT} — a redirect
224
+ # hop (e.g. the `/resources/:noid` resolver) is bracketed with the request
225
+ # it redirects to, not counted twice. Guarded on
226
+ # `defined?(ActiveSupport::Notifications)` because Faraday defaults its
227
+ # instrumenter to that constant and would `NameError` at build time on the
228
+ # headless path where ActiveSupport isn't loaded; there, the emit is simply
229
+ # never wired and the transport is unaffected.
230
+ def instrument(builder)
231
+ return unless defined?(ActiveSupport::Notifications)
232
+
233
+ builder.request :instrumentation, name: INSTRUMENTATION_EVENT
234
+ end
235
+
200
236
  # Build the auth + identity headers shared by {#connection} and {#multipart}.
201
237
  # Precedence: ATLAS_JWT (BYO-JWT) > relay-signing. The acting nuid /
202
238
  # on_behalf_of fall through to the configured `default_nuid` /
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.8.9
4
+ version: 1.8.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cliff