network_resiliency 0.7.13 → 0.7.14
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 +4 -0
- data/Gemfile.lock +1 -1
- data/lib/network_resiliency/version.rb +1 -1
- data/lib/network_resiliency.rb +20 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8515a542f0e3d22b8e562187dcc23325c8c89866c2e708cf540cb73894195471
|
4
|
+
data.tar.gz: 30cd44b2ad019321587b8d29f0afc28cde9070f88ded257799e1bcb1aa3dc7e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0530fb98688ef75f2cccd2bbe4e75c835bbf20ca3cbdec307c26f9ed9bc04462361867f96ecbf001dc81c36675b1024dca2e09f80b0fa8e71fc623d0540849d2
|
7
|
+
data.tar.gz: 2de979e7c792a32f7993625a529d31a7b35616c51c17aedea97acd2884f0a589144ec2bbb81cf6cb0f8a50591c3bc414cff7e3253643cb46c266ecf0cb8d2458
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/network_resiliency.rb
CHANGED
@@ -19,8 +19,9 @@ module NetworkResiliency
|
|
19
19
|
|
20
20
|
ACTIONS = [ :connect, :request ].freeze
|
21
21
|
ADAPTERS = [ :http, :faraday, :redis, :mysql, :postgres, :rails ].freeze
|
22
|
+
DEFAULT_TIMEOUT_MIN = 10 # ms
|
22
23
|
MODE = [ :observe, :resilient ].freeze
|
23
|
-
|
24
|
+
RESILIENCY_THRESHOLD = 300
|
24
25
|
SAMPLE_RATE = {
|
25
26
|
timeout: 0.1,
|
26
27
|
stats: 0.1,
|
@@ -216,6 +217,18 @@ module NetworkResiliency
|
|
216
217
|
end
|
217
218
|
end
|
218
219
|
|
220
|
+
def timeout_min=(val)
|
221
|
+
unless val.nil? || val.is_a?(Numeric)
|
222
|
+
raise ArgumentError, "invalid timeout_min: #{val}"
|
223
|
+
end
|
224
|
+
|
225
|
+
@timeout_min = val
|
226
|
+
end
|
227
|
+
|
228
|
+
def timeout_min
|
229
|
+
@timeout_min || DEFAULT_TIMEOUT_MIN
|
230
|
+
end
|
231
|
+
|
219
232
|
# private
|
220
233
|
|
221
234
|
def record(adapter:, action:, destination:, duration:, error:, timeout:, attempts: 1)
|
@@ -258,7 +271,7 @@ module NetworkResiliency
|
|
258
271
|
key = [ adapter, action, destination ].join(":")
|
259
272
|
stats = StatsEngine.add(key, duration)
|
260
273
|
|
261
|
-
if stats.n >
|
274
|
+
if stats.n > RESILIENCY_THRESHOLD * 4
|
262
275
|
# downsample to age out old stats
|
263
276
|
stats.scale!(50)
|
264
277
|
end
|
@@ -317,7 +330,7 @@ module NetworkResiliency
|
|
317
330
|
key = [ adapter, action, destination ].join(":")
|
318
331
|
stats = StatsEngine.get(key)
|
319
332
|
|
320
|
-
return default unless stats.n >=
|
333
|
+
return default unless stats.n >= RESILIENCY_THRESHOLD
|
321
334
|
|
322
335
|
tags = {
|
323
336
|
adapter: adapter,
|
@@ -325,7 +338,9 @@ module NetworkResiliency
|
|
325
338
|
destination: destination,
|
326
339
|
}
|
327
340
|
|
328
|
-
p99 = (stats.avg + stats.stdev * 2).order_of_magnitude(ceil: true)
|
341
|
+
# p99 = (stats.avg + stats.stdev * 2).order_of_magnitude(ceil: true)
|
342
|
+
p99 = (stats.avg + stats.stdev * 3).power_ceil
|
343
|
+
p99 = [ p99, timeout_min ].max
|
329
344
|
|
330
345
|
timeouts = []
|
331
346
|
|
@@ -402,6 +417,7 @@ module NetworkResiliency
|
|
402
417
|
@mode = nil
|
403
418
|
@normalize_request = nil
|
404
419
|
@patched = nil
|
420
|
+
@timeout_min = nil
|
405
421
|
Thread.current["network_resiliency"] = nil
|
406
422
|
StatsEngine.reset
|
407
423
|
Syncer.stop
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: network_resiliency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Pepper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|