rookout 0.1.40 → 0.1.42

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: 7605e9deab6fab2b1456185132e9db8100f143e0486a6cbef13a20a368047ad1
4
- data.tar.gz: 900c58be123cfad2b749a16dce8ed3e6fa572af1177ee3778fe9318c02a2f81b
3
+ metadata.gz: 1b7b251222795c20881099bbd6f64cb0e9c66c24f837403aecc29d5fc8737d22
4
+ data.tar.gz: 488333717b7f9a0ef507d5a621caa4a37a99bd87a3f966e63808ba773aeb83ef
5
5
  SHA512:
6
- metadata.gz: 0d4bf7792481a091c0110353cf727f44486b08dd099bba996ce83c7b05e88213f8a714dcbfb2840944876a49a8a794f2496c501c1c19ec5c341f1493ab925ace
7
- data.tar.gz: 5069a96af2a1a11b0e7d07be6def3a42bdbf0b94658bc16ff652d06ae623295f5c9b4ea02cbee21cae3d68a236f283568d0136d04edcc51937c68c4a31ba635b
6
+ metadata.gz: fc9945c4fad24e0ebdee3bb83a1f71d353cef33bd14f9881007324ad2e82aba3292ba63cf54e54c14922547b1b68f6da58a1cdff99426dfd2a9bb85da78516cc
7
+ data.tar.gz: 1848074ffaa23f2632457e42dec7c04f4527cb4cad80af234e9bc7dc3c7c72f63c786ee7dfcae3e1e3bff44eb8665fcfabf5be7dcde2ead58eb3234d72909796
@@ -27,7 +27,7 @@ module Rookout
27
27
  return unless @enabled
28
28
 
29
29
  if output.user_messages_queue_full?
30
- Logger.instance.warning "Skipping aug-\t#{id} execution because the queue is full"
30
+ output.send_output_queue_full_warning @id
31
31
  return
32
32
  end
33
33
 
@@ -67,8 +67,10 @@ module Rookout
67
67
  def create_limits_manager configuration
68
68
  limiters = []
69
69
  if global_rate_limiter.nil?
70
- rate_limit = parse_rate_limit configuration["rateLimit"], configuration["rateLimitModifier"], 200, 5000
71
- limiters.append AugRateLimiter.new(*rate_limit)
70
+ rate_limit = parse_rate_limit configuration["rateLimit"], configuration["rateLimitModifier"], 200, 5000, 1
71
+ unless rate_limit.nil?
72
+ limiters.append AugRateLimiter.new(*rate_limit)
73
+ end
72
74
  else
73
75
  limiters.append global_rate_limiter
74
76
  end
@@ -77,8 +79,20 @@ module Rookout
77
79
  end
78
80
 
79
81
  def global_rate_limiter
80
- if @global_rate_limiter.nil? && !Rookout::Config.global_rate_limit.nil?
81
- rate_limit = parse_rate_limit Rookout::Config.global_rate_limit, "0", 0, 0
82
+ if @global_rate_limiter.nil? && Rookout::Config.global_rate_limit != ""
83
+ begin
84
+ rate_limit = parse_rate_limit Rookout::Config.global_rate_limit,
85
+ "0", 0, 0, Rookout::Config.global_rate_limit_multiplier
86
+ if rate_limit.nil?
87
+ raise Exceptions::RookInvalidRateLimitConfiguration, Rookout::Config.global_rate_limit
88
+ end
89
+ rescue Exceptions::RookInvalidRateLimitConfiguration => e
90
+ Logger.instance.warning "Failed to create global rate limiter: #{e.message}"
91
+ err = Processor::RookError.new e
92
+ UserWarnings.notify_error err
93
+ return nil
94
+ end
95
+
82
96
  @global_rate_limiter = AugRateLimiter.new(*rate_limit)
83
97
  Logger.instance.debug "Using global rate limiter with configuration: #{rate_limit}"
84
98
  Rookout::Config.using_global_rate_limiter = true
@@ -87,7 +101,7 @@ module Rookout
87
101
  @global_rate_limiter
88
102
  end
89
103
 
90
- def parse_rate_limit config, modifier_config, default_quota, default_window
104
+ def parse_rate_limit config, modifier_config, default_quota, default_window, multiplier
91
105
  window_quota = default_quota
92
106
  window_size = default_window
93
107
 
@@ -105,7 +119,15 @@ module Rookout
105
119
  window_size_ns = Utils.milliseconds_to_nanoseconds window_size
106
120
  rate_limit_modifier = modifier_config.to_i || 5
107
121
 
108
- [window_quota_ns, window_size_ns, rate_limit_modifier]
122
+ if window_quota_ns == 0
123
+ return nil
124
+ end
125
+
126
+ if window_quota_ns >= window_size_ns
127
+ raise Exceptions::RookInvalidRateLimitConfiguration, config
128
+ end
129
+
130
+ [window_quota_ns * multiplier, window_size_ns, rate_limit_modifier]
109
131
  end
110
132
  end
111
133
  end
@@ -26,8 +26,12 @@ module Rookout
26
26
  attr_reader :pending_messages
27
27
 
28
28
  def initialize output, agent_host, agent_port, proxy, token, labels, print_on_connect
29
- agent_host_with_protocl = agent_host.include?("://") ? agent_host : "ws://#{agent_host}"
30
- @uri = "#{agent_host_with_protocl}:#{agent_port}/v1"
29
+ if agent_host.nil? || agent_host.empty?
30
+ @uri = ""
31
+ else
32
+ agent_host_with_protocl = agent_host.include?("://") ? agent_host : "ws://#{agent_host}"
33
+ @uri = "#{agent_host_with_protocl}:#{agent_port}/v1"
34
+ end
31
35
  if proxy.nil? || proxy.empty?
32
36
  @proxy = nil
33
37
  else
@@ -57,14 +61,7 @@ module Rookout
57
61
  msg_size = envelope_wrapper.calculate_size
58
62
  if @pending_messages_length + msg_size > Config.agent_com_max_queue_messages_length ||
59
63
  queue_full?
60
- exc = Exceptions::RookMessageSizeExceeded.new msg_size, Config.agent_com_max_queue_messages_length
61
- warning = Processor::RookError.new exc
62
- UserWarnings.notify_warning warning
63
-
64
- Logger.instance.warning "Dropping message, size was #{msg_size}, pedning messages: #{@pending_messages_length}
65
- which is over the message size limit #{Config.agent_com_max_queue_messages_length},
66
- queue length: #{@pending_messages.length}"
67
- return
64
+ raise Exceptions::RookOutputQueueFull
68
65
  end
69
66
 
70
67
  @pending_messages.push envelope_wrapper
@@ -11,11 +11,15 @@ module Rookout
11
11
  require_relative "token_bucket"
12
12
  require_relative "envelope_wrapper"
13
13
 
14
+ require "concurrent"
15
+
14
16
  class Output
15
17
  def initialize
16
18
  @agent_id = nil
17
19
  @agent_com = nil
18
20
 
21
+ @skipped_aug_ids = Concurrent::Set.new
22
+
19
23
  @rule_status_update_bucket = TokenBucket.new Config.output_max_status_updates,
20
24
  Config.output_bucket_refresh_rate do
21
25
  Logger.instance.error "Limit reached, dropping status updates"
@@ -55,6 +59,17 @@ module Rookout
55
59
  @user_message_bucket.exhausted? || (!@agent_com.nil? && @agent_com.queue_full?)
56
60
  end
57
61
 
62
+ def send_output_queue_full_warning aug_id
63
+ if @skipped_aug_ids.include? aug_id
64
+ return
65
+ end
66
+
67
+ @skipped_aug_ids.add aug_id
68
+ error = Processor::RookError.new Exceptions::RookOutputQueueFull.new
69
+ send_rule_status aug_id, :Warning, error
70
+ Logger.instance.warning "Skipping aug-\t#{aug_id} execution because the queue is full"
71
+ end
72
+
58
73
  def send_warning rule_id, error
59
74
  send_rule_status rule_id, :Warning, error
60
75
  end
@@ -63,6 +78,10 @@ module Rookout
63
78
  return if @closing || !@agent_com
64
79
 
65
80
  @rule_status_update_bucket.if_available do
81
+ if active == "Deleted"
82
+ @skipped_aug_ids.delete? rule_id
83
+ end
84
+
66
85
  status = Com::Rookout::RuleStatusMessage.new agent_id: @agent_id,
67
86
  rule_id: rule_id,
68
87
  active: active
@@ -73,7 +92,11 @@ module Rookout
73
92
 
74
93
  envelope_wrapper = EnvelopeWrapper.new status
75
94
 
76
- @agent_com.add envelope_wrapper
95
+ begin
96
+ @agent_com.add envelope_wrapper
97
+ rescue Exceptions::RookOutputQueueFull
98
+ # Ignored
99
+ end
77
100
  end
78
101
  end
79
102
 
@@ -100,7 +123,12 @@ module Rookout
100
123
  )
101
124
  end
102
125
 
103
- @agent_com.add envelope_wrapper
126
+ begin
127
+ @agent_com.add envelope_wrapper
128
+ @skipped_aug_ids.delete? aug_id
129
+ rescue Exceptions::RookOutputQueueFull
130
+ send_output_queue_full_warning aug_id
131
+ end
104
132
  end
105
133
  end
106
134
 
@@ -144,7 +172,11 @@ module Rookout
144
172
 
145
173
  envelope_wrapper = EnvelopeWrapper.new msg
146
174
 
147
- @agent_com.add envelope_wrapper
175
+ begin
176
+ @agent_com.add envelope_wrapper
177
+ rescue Exceptions::RookOutputQueueFull
178
+ # Ignored
179
+ end
148
180
  end
149
181
  end
150
182
  end
@@ -1,3 +1,3 @@
1
1
  module Rookout
2
- COMMIT = "c62d573f33d1f62ad05aec7d28a4757fafb9a2b4".freeze
2
+ COMMIT = "17ed82e31d57aaaecc1244c11f0e10e673069d7e".freeze
3
3
  end
@@ -76,10 +76,16 @@ module Rookout
76
76
 
77
77
  Rookout::Config.true_values = ["y", "Y", "yes", "Yes", "YES", "true", "True", "TRUE", "1"]
78
78
 
79
+ attr_accessor :global_rate_limit_quota
80
+ attr_accessor :global_rate_limit_window_size
79
81
  attr_accessor :global_rate_limit
82
+ attr_accessor :global_rate_limit_multiplier
80
83
  attr_accessor :using_global_rate_limiter
81
84
 
82
- Rookout::Config.global_rate_limit = nil
85
+ Rookout::Config.global_rate_limit_quota = ""
86
+ Rookout::Config.global_rate_limit_window_size = ""
87
+ Rookout::Config.global_rate_limit = ""
88
+ Rookout::Config.global_rate_limit_multiplier = 1
83
89
  Rookout::Config.using_global_rate_limiter = false
84
90
 
85
91
  def update_config configuration
@@ -103,10 +109,15 @@ module Rookout
103
109
  def update_global_rate_limit_config configuration
104
110
  global_rate_limit = ENV["ROOKOUT_GLOBAL_RATE_LIMIT"]
105
111
  if global_rate_limit.nil?
106
- global_rate_limit = configuration["RUBY_GLOBAL_RATE_LIMIT"]
112
+ quota = configuration["RUBY_GLOBAL_RATE_LIMIT_QUOTA_MS"]
113
+ window_size = configuration["RUBY_GLOBAL_RATE_LIMIT_WINDOW_SIZE_MS"]
114
+
115
+ if quota != "" && window_size != ""
116
+ global_rate_limit = "#{quota}/#{window_size}"
117
+ end
107
118
  end
108
119
 
109
- return if global_rate_limit.nil?
120
+ return if global_rate_limit.nil? || global_rate_limit == ""
110
121
 
111
122
  @global_rate_limit = global_rate_limit
112
123
  Logger.instance.info "Updating global rate limit to: #{global_rate_limit}"
@@ -95,6 +95,13 @@ module Rookout
95
95
  end
96
96
  end
97
97
 
98
+ class RookOutputQueueFull < ToolException
99
+ def initialize
100
+ super "Breakpoint triggered but output queue is full. " \
101
+ "Data collection will be disabled until the queue has emptied."
102
+ end
103
+ end
104
+
98
105
  class RookRuleAugRateLimited < ToolException
99
106
  def initialize
100
107
  super "Breakpoint was disabled due to rate-limiting. " \
@@ -1,3 +1,3 @@
1
1
  module Rookout
2
- VERSION = "0.1.40".freeze
2
+ VERSION = "0.1.42".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rookout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.40
4
+ version: 0.1.42
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liran Haimovitch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-11 00:00:00.000000000 Z
11
+ date: 2022-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: binding_of_caller