network_resiliency 0.7.13 → 0.7.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c006caf6d6fefeca3185a0a6a1d75be6bcf1cbc16ed9e1b00f2b147114b8442f
4
- data.tar.gz: cad33936cc88b7d586b9b1ca92ab36308e37af11768509e67fb6f20e2af354ba
3
+ metadata.gz: 61590ba8f759273c9da124ffec0f12b42cc49663d14d6bf1bd75ebb4d73639b2
4
+ data.tar.gz: 2dbd88e94b47a53990fb2328f65cc614be4cb8580e91e17afac0b35f06db281a
5
5
  SHA512:
6
- metadata.gz: e4eaf6bf8b4a4b176a8bd2ae3b79a80fc1a9b01c0d0a6dc486e870d656eb3793c1626dd923c2afd1c2b06774012067d77815a1710e5de44f06d79f098dd8db2b
7
- data.tar.gz: 36d9406a01c76ca09d0859194401bbd49a177f644c1ca38d5df3c1fb8ad27907304d8d17ad2c165ced7dcfc67b467ee4e2061ce63e80a884fc8a5a372e994f2b
6
+ metadata.gz: ca543341cabe254a16b9cb3d035640c29b719bc721a542d3cfd6bc764af8fd20dfa6fb3f57cd2662997f3b5270574b729ae2402b49625a946c37f3c10633de60
7
+ data.tar.gz: 232af6a8de1a7ef893e0e1d745d4d12980fc71cb31156c591584ab38967993168986a9778b41ad842eae363704e3b7e49d9ec8d90755a41da056478046d0b242
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ### v0.7.15 (2024-03-08)
2
+ - higher def timeouts
3
+
4
+ ### v0.7.14 (2024-03-07)
5
+ - lower dynamic timeout
6
+ - timeout-min
7
+
1
8
  ### v0.7.13 (2024-03-04)
2
9
  - downsampling
3
10
  - redis resiliency
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- network_resiliency (0.7.13)
4
+ network_resiliency (0.7.15)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module NetworkResiliency
2
- VERSION = "0.7.13"
2
+ VERSION = "0.7.15"
3
3
  end
@@ -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
- RESILIENCY_SIZE_THRESHOLD = 300
24
+ RESILIENCY_THRESHOLD = 100
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 > RESILIENCY_SIZE_THRESHOLD * 4
274
+ if stats.n > RESILIENCY_THRESHOLD * 5
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 >= RESILIENCY_SIZE_THRESHOLD
333
+ return default unless stats.n >= RESILIENCY_THRESHOLD
321
334
 
322
335
  tags = {
323
336
  adapter: adapter,
@@ -325,7 +338,18 @@ 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 * 3)
342
+
343
+ # add margin of error / normalize
344
+ p99 = if stats.n >= RESILIENCY_THRESHOLD * 2
345
+ p99.power_ceil
346
+ else
347
+ # larger margin of error
348
+ p99.order_of_magnitude(ceil: true)
349
+ end
350
+
351
+ # enforce minimum timeout
352
+ p99 = [ p99, timeout_min ].max
329
353
 
330
354
  timeouts = []
331
355
 
@@ -402,6 +426,7 @@ module NetworkResiliency
402
426
  @mode = nil
403
427
  @normalize_request = nil
404
428
  @patched = nil
429
+ @timeout_min = nil
405
430
  Thread.current["network_resiliency"] = nil
406
431
  StatsEngine.reset
407
432
  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.13
4
+ version: 0.7.15
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-04 00:00:00.000000000 Z
11
+ date: 2024-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug