rookout 0.1.41 → 0.1.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rookout/augs/aug.rb +1 -1
- data/lib/rookout/augs/aug_factory.rb +27 -5
- data/lib/rookout/com_ws/agent_com_ws.rb +7 -10
- data/lib/rookout/com_ws/output.rb +35 -3
- data/lib/rookout/commit.rb +1 -1
- data/lib/rookout/config.rb +12 -1
- data/lib/rookout/exceptions.rb +7 -0
- data/lib/rookout/version.rb +1 -1
- 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: 1b7b251222795c20881099bbd6f64cb0e9c66c24f837403aecc29d5fc8737d22
|
4
|
+
data.tar.gz: 488333717b7f9a0ef507d5a621caa4a37a99bd87a3f966e63808ba773aeb83ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc9945c4fad24e0ebdee3bb83a1f71d353cef33bd14f9881007324ad2e82aba3292ba63cf54e54c14922547b1b68f6da58a1cdff99426dfd2a9bb85da78516cc
|
7
|
+
data.tar.gz: 1848074ffaa23f2632457e42dec7c04f4527cb4cad80af234e9bc7dc3c7c72f63c786ee7dfcae3e1e3bff44eb8665fcfabf5be7dcde2ead58eb3234d72909796
|
data/lib/rookout/augs/aug.rb
CHANGED
@@ -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
|
-
|
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
|
@@ -78,7 +80,19 @@ module Rookout
|
|
78
80
|
|
79
81
|
def global_rate_limiter
|
80
82
|
if @global_rate_limiter.nil? && Rookout::Config.global_rate_limit != ""
|
81
|
-
|
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
|
-
|
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
|
-
|
30
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/rookout/commit.rb
CHANGED
data/lib/rookout/config.rb
CHANGED
@@ -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
|
|
85
|
+
Rookout::Config.global_rate_limit_quota = ""
|
86
|
+
Rookout::Config.global_rate_limit_window_size = ""
|
82
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,7 +109,12 @@ 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
|
-
|
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
120
|
return if global_rate_limit.nil? || global_rate_limit == ""
|
data/lib/rookout/exceptions.rb
CHANGED
@@ -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. " \
|
data/lib/rookout/version.rb
CHANGED
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.
|
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
|
+
date: 2022-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: binding_of_caller
|