rookout 0.1.36 → 0.1.39

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rookout/augs/actions/action_run_processor.rb +1 -0
  3. data/lib/rookout/augs/aug.rb +3 -5
  4. data/lib/rookout/augs/aug_factory.rb +40 -16
  5. data/lib/rookout/augs/aug_rate_limiter.rb +35 -36
  6. data/lib/rookout/augs/limits_manager.rb +31 -0
  7. data/lib/rookout/augs/locations/location_file_line.rb +5 -1
  8. data/lib/rookout/com_ws/agent_com_ws.rb +4 -3
  9. data/lib/rookout/com_ws/envelope_wrapper.rb +7 -5
  10. data/lib/rookout/com_ws/git.rb +1 -1
  11. data/lib/rookout/com_ws/information.rb +2 -1
  12. data/lib/rookout/com_ws/output.rb +13 -7
  13. data/lib/rookout/commit.rb +1 -1
  14. data/lib/rookout/config.rb +55 -17
  15. data/lib/rookout/exceptions.rb +12 -9
  16. data/lib/rookout/interface.rb +9 -8
  17. data/lib/rookout/logger.rb +13 -7
  18. data/lib/rookout/processor/namespace_serializer.rb +1 -1
  19. data/lib/rookout/processor/namespace_serializer2.rb +26 -12
  20. data/lib/rookout/processor/namespaces/container_namespace.rb +1 -0
  21. data/lib/rookout/processor/namespaces/frame_namespace.rb +2 -3
  22. data/lib/rookout/processor/namespaces/namespace.rb +1 -0
  23. data/lib/rookout/processor/namespaces/noop_namespace.rb +0 -4
  24. data/lib/rookout/processor/namespaces/ruby_object_namespace.rb +31 -16
  25. data/lib/rookout/processor/namespaces/ruby_object_serializer.rb +9 -7
  26. data/lib/rookout/processor/namespaces/ruby_utils_namespace.rb +0 -4
  27. data/lib/rookout/processor/namespaces/stack_namespace.rb +1 -0
  28. data/lib/rookout/processor/namespaces/traceback_namespace.rb +4 -1
  29. data/lib/rookout/processor/operations/set_operation.rb +2 -0
  30. data/lib/rookout/processor/paths/arithmetic_path.rb +3 -1
  31. data/lib/rookout/processor/paths/canopy/actions.rb +5 -1
  32. data/lib/rookout/processor/paths/canopy/consts.rb +6 -4
  33. data/lib/rookout/processor/paths/canopy/markers.rb +15 -5
  34. data/lib/rookout/processor/processor_factory.rb +0 -2
  35. data/lib/rookout/processor/rook_error.rb +3 -1
  36. data/lib/rookout/rookout_singleton.rb +3 -2
  37. data/lib/rookout/sanitizer.rb +22 -0
  38. data/lib/rookout/services/position.rb +3 -2
  39. data/lib/rookout/services/tracer.rb +2 -2
  40. data/lib/rookout/utils.rb +7 -1
  41. data/lib/rookout/version.rb +1 -1
  42. data/lib/rookout.rb +4 -0
  43. metadata +41 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40c3d2b4b3e7cf49a817115416ff9ac23fb2078c036744f31cbba5a187dd933f
4
- data.tar.gz: fc57b64eb454574b754dcbfc6ea4f0fdc7579794f073f4290f4a11b336f76c10
3
+ metadata.gz: fb5d9fef64ead13081355d267ad49671d0ca9ddf3e916ab5cf556d6d3b5997be
4
+ data.tar.gz: e114be3eb5224761c01f5a64bd4f367a90effed5d130c61f90ab4a8328152928
5
5
  SHA512:
6
- metadata.gz: cfb0aca8f7fb82ccb39adb8c8f03f5b5242c22bb43dc23bf68f80b18d300e06e11eec8a4885edc3d8eddba58d792db254bbcb6070c030ca2d9f675557ad8a98d
7
- data.tar.gz: fdc04d582ee9a9bc76a7b9e12ffeaa0a04be2e70a6fdfd7a3841d65ae9a088d947f97df3aaf9f65e1cdd26e0f3a4ef111ea992417eb50581dcbddc682c5716bc
6
+ metadata.gz: 1da019cfc4c4cbeada393163a6fb4fa01826fdfe9d76edfd0926218b40d6dbedafb2291de4c63a558ac521bf6d360fee76a8522b2a10d021ce7d3538ce1ae530
7
+ data.tar.gz: 0a24f0bee3b44a23c9ad1ab7e1cdd6c6fc694e50358abd9d96b219ab3a5116c6567ebfd94a498de0de3cda523605fe2d0d27617d3aca7a9161689eeaa9132131
@@ -5,6 +5,7 @@ module Rookout
5
5
  module Actions
6
6
  class ActionRunProcessor < Action
7
7
  def initialize arguments, processor_factory
8
+ super()
8
9
  @processor = processor_factory.create_processor arguments["operations"]
9
10
 
10
11
  post_operations = arguments["post_operations"]
@@ -10,13 +10,11 @@ module Rookout
10
10
  require_relative "../logger"
11
11
 
12
12
  class Aug
13
- def initialize aug_id, action, condition, rate_limiter, _max_aug_time
14
- # NOTE: max_aux_time is not implemented
15
-
13
+ def initialize aug_id, action, condition, limits_manager, _max_aug_time
16
14
  @id = aug_id
17
15
  @action = action
18
16
  @condition = condition
19
- @rate_limiter = rate_limiter
17
+ @limits_manager = limits_manager
20
18
 
21
19
  @enabled = true
22
20
  @status = nil
@@ -36,7 +34,7 @@ module Rookout
36
34
  namespace = create_namespaces frame, extracted
37
35
  return if @condition && !@condition.evaluate(namespace)
38
36
 
39
- @rate_limiter.with_limit do
37
+ @limits_manager.with_limit do
40
38
  report_id = Utils.uuid
41
39
  Logger.instance.info "Executing aug-\t#{id} (msg ID #{report_id})"
42
40
  @action.execute @id, report_id, namespace, output
@@ -10,7 +10,9 @@ module Rookout
10
10
  require_relative "locations/location_exception_handler"
11
11
  require_relative "aug_rate_limiter"
12
12
  require_relative "aug"
13
+ require_relative "limits_manager"
13
14
  require_relative "../utils"
15
+ require_relative "../logger"
14
16
 
15
17
  class AugFactory
16
18
  def initialize output
@@ -34,10 +36,10 @@ module Rookout
34
36
  end
35
37
  condition = condition_configuration.nil? ? nil : Conditions::Condition.new(condition_configuration)
36
38
 
37
- rate_limit = create_rate_limit configuration
39
+ limits_manager = create_limits_manager configuration
38
40
 
39
41
  max_aug_time_ns = Utils.milliseconds_to_nanoseconds max_aug_time
40
- aug = Aug.new aug_id, action, condition, rate_limit, max_aug_time_ns
42
+ aug = Aug.new aug_id, action, condition, limits_manager, max_aug_time_ns
41
43
 
42
44
  location_configuration = configuration["location"]
43
45
  raise Exceptions::RookAugInvalidKey.new("location", configuration) unless location_configuration.is_a? Hash
@@ -52,9 +54,9 @@ module Rookout
52
54
 
53
55
  case name
54
56
  when "file_line"
55
- return Locations::LocationFileLine.new configuration, @output, aug
57
+ Locations::LocationFileLine.new configuration, @output, aug
56
58
  when "exception_handler"
57
- return Locations::LocationExceptionHandler.new configuration, @output, aug
59
+ Locations::LocationExceptionHandler.new configuration, @output, aug
58
60
  when "log_handler"
59
61
  raise Exceptions::RookUnsupportedLiveLogger
60
62
  else
@@ -62,25 +64,47 @@ module Rookout
62
64
  end
63
65
  end
64
66
 
65
- def create_rate_limit configuration
66
- window_quota = 200
67
- window_size = 5000
67
+ def create_limits_manager configuration
68
+ limiters = []
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)
72
+ else
73
+ limiters.append global_rate_limiter
74
+ end
68
75
 
69
- rate_limit = configuration["rateLimit"]
70
- if rate_limit
71
- rate_limit_splitted = rate_limit.split "/"
72
- if rate_limit_splitted.length == 2
73
- window_quota = rate_limit_splitted[0].to_i
74
- window_size = rate_limit_splitted[1].to_i
75
- end
76
+ LimitsManager.new limiters
77
+ end
78
+
79
+ 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
+ @global_rate_limiter = AugRateLimiter.new(*rate_limit)
83
+ Logger.instance.debug "Using global rate limiter with configuration: #{rate_limit}"
76
84
  end
77
85
 
78
- rate_limit_modifier = configuration["rateLimitModifier"] || 5
86
+ @global_rate_limiter
87
+ end
88
+
89
+ def parse_rate_limit config, modifier_config, default_quota, default_window
90
+ window_quota = default_quota
91
+ window_size = default_window
92
+
93
+ unless config.nil? || config.empty?
94
+ rate_limit_split = config.split "/"
95
+ unless rate_limit_split.length == 2 && rate_limit_split[0].is_number? && rate_limit_split[1].is_number?
96
+ raise Exceptions::RookInvalidRateLimitConfiguration, config
97
+ end
98
+
99
+ window_quota = rate_limit_split[0].to_i
100
+ window_size = rate_limit_split[1].to_i
101
+ end
79
102
 
80
103
  window_quota_ns = Utils.milliseconds_to_nanoseconds window_quota
81
104
  window_size_ns = Utils.milliseconds_to_nanoseconds window_size
105
+ rate_limit_modifier = modifier_config.to_i || 5
82
106
 
83
- AugRateLimiter.new window_quota_ns, window_size_ns, rate_limit_modifier
107
+ [window_quota_ns, window_size_ns, rate_limit_modifier]
84
108
  end
85
109
  end
86
110
  end
@@ -8,51 +8,50 @@ module Rookout
8
8
  @quota = quota
9
9
  @has_quota = !@quota.nil? && (@quota > 0)
10
10
  @window_size = window_size
11
- @active_weight = quota / active_limit
11
+ if active_limit > 0
12
+ @active_weight = quota / active_limit
13
+ else
14
+ @active_weight = 0
15
+ end
12
16
 
13
17
  @mutex = Mutex.new
14
18
  @active_count = 0
15
19
  @windows = {}
16
20
  end
17
21
 
18
- def with_limit start_time = nil
19
- active = false
20
- start_time ||= Time.now
21
-
22
- # If quota, verify it
23
- if @has_quota
24
- # Get current time
25
- now_ns = Utils.time_to_nanoseconds start_time
26
-
27
- # Calculate window keys
28
- current_window_key, prev_window_key = timestamp_to_window_keys now_ns
29
-
30
- @mutex.synchronize do
31
- # Clean old windows
32
- cleanup now_ns
33
- # Increase active count
34
- @active_count += 1
35
- active = true
36
-
37
- # If exceeding quota
38
- if current_usage(now_ns, current_window_key, prev_window_key) > @quota
39
- warning = Processor::RookError.new Exceptions::RookRuleRateLimited.new
40
- UserWarnings.notify_warning warning
41
- return
42
- end
22
+ def before_run start_time
23
+ # If no quota, we can safely exit
24
+ unless @has_quota
25
+ return true
26
+ end
27
+ now_ns = Utils.time_to_nanoseconds start_time
28
+ current_window_key, prev_window_key = timestamp_to_window_keys now_ns
29
+
30
+ @mutex.synchronize do
31
+ # Clean old windows
32
+ cleanup now_ns
33
+ usage = current_usage now_ns, current_window_key, prev_window_key
34
+ @active_count += 1
35
+
36
+ # If exceeding quota
37
+ if usage > @quota
38
+ warning = Processor::RookError.new Exceptions::RookRuleRateLimited.new
39
+ UserWarnings.notify_warning warning
40
+ return false
43
41
  end
42
+
43
+ return true
44
44
  end
45
+ end
45
46
 
46
- begin
47
- yield
48
- ensure
49
- if @has_quota
50
- @mutex.synchronize { record_usage current_window_key, Utils.time_to_nanoseconds(Time.now) - now_ns }
51
- end
47
+ def after_run start_time
48
+ if @has_quota
49
+ now_ns = Utils.time_to_nanoseconds start_time
50
+ current_window_key, = timestamp_to_window_keys now_ns
51
+ @mutex.synchronize { record_usage current_window_key, Utils.time_to_nanoseconds(Time.now) - now_ns }
52
52
  end
53
- ensure
54
53
  # Reduce active count
55
- @mutex.synchronize { @active_count -= 1 } if active
54
+ @mutex.synchronize { @active_count -= 1 }
56
55
  end
57
56
 
58
57
  private
@@ -75,7 +74,7 @@ module Rookout
75
74
  prev_window_usage = @windows[prev_window_key] || 0
76
75
 
77
76
  # Previous window weight
78
- prev_weight = 1 - (now_ns - current_window_key) / @window_size.to_f
77
+ prev_weight = 1 - ((now_ns - current_window_key) / @window_size.to_f)
79
78
 
80
79
  # Final weighted usage
81
80
  (prev_window_usage * prev_weight) + (@active_count * @active_weight) + current_window_usage
@@ -91,7 +90,7 @@ module Rookout
91
90
  end
92
91
 
93
92
  def cleanup now_ns
94
- @windows.reject! { |key, _| key < (now_ns - @window_size * 5) } if @windows.length > 10
93
+ @windows.reject! { |key, _| key < (now_ns - (@window_size * 5)) } if @windows.length > 10
95
94
  end
96
95
  end
97
96
  end
@@ -0,0 +1,31 @@
1
+ module Rookout
2
+ module Augs
3
+ class LimitsManager
4
+ def initialize limiters
5
+ @limiters = limiters
6
+ end
7
+
8
+ def with_limit start_time = nil
9
+ start_time ||= Time.now
10
+ can_execute = true
11
+ after_execute = []
12
+
13
+ @limiters.each do |limiter|
14
+ if limiter.before_run start_time
15
+ after_execute.append -> { limiter.after_run start_time }
16
+ else
17
+ can_execute = false
18
+ end
19
+ end
20
+
21
+ if can_execute
22
+ yield
23
+ end
24
+ ensure
25
+ unless after_execute.nil?
26
+ after_execute.each(&:call)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -21,7 +21,11 @@ module Rookout
21
21
  @line_unique = arguments["line_unique"] || false
22
22
  end
23
23
 
24
- attr_reader :filename, :lineno, :file_hash, :line_crc, :line_unique
24
+ attr_reader :filename
25
+ attr_reader :lineno
26
+ attr_reader :file_hash
27
+ attr_reader :line_crc
28
+ attr_reader :line_unique
25
29
 
26
30
  def add_aug trigger_services
27
31
  trigger_services.get_service("position").add_aug self
@@ -118,7 +118,7 @@ module Rookout
118
118
 
119
119
  if @print_on_initial_connection
120
120
  @print_on_initial_connection = false
121
- STDERR.puts "[Rookout] Successfully connected to controller"
121
+ $stderr.puts "[Rookout] Successfully connected to controller"
122
122
  end
123
123
  Logger.instance.debug "WebSocket connected successfully"
124
124
  Logger.instance.info "Finished initialization"
@@ -205,9 +205,10 @@ module Rookout
205
205
  msg = envelope_wrapper.envelope
206
206
  @pending_messages_length -= envelope_wrapper.calculate_size
207
207
 
208
- if msg.is_a? ExitMessage
208
+ case msg
209
+ when ExitMessage
209
210
  break if msg.thread == Thread.current
210
- elsif msg.is_a? FlushMessage
211
+ when FlushMessage
211
212
  msg.event.set
212
213
  else
213
214
  begin
@@ -8,8 +8,7 @@ class EnvelopeWrapperBase
8
8
  timestamp = Google::Protobuf::Timestamp.new
9
9
  timestamp.from_time Time.new
10
10
  envelope = Com::Rookout::Envelope.new msg: any_message, timestamp: timestamp
11
- serialized = Com::Rookout::Envelope.encode envelope
12
- serialized
11
+ Com::Rookout::Envelope.encode envelope
13
12
  end
14
13
 
15
14
  def envelope
@@ -23,11 +22,13 @@ end
23
22
 
24
23
  class Variant2EnvelopeWrapper < EnvelopeWrapperBase
25
24
  def initialize agent_id, aug_id, report_id, arguments
25
+ super()
26
+
26
27
  @aug_report_message = Com::Rookout::AugReportMessage.new agent_id: agent_id,
27
- aug_id: aug_id,
28
- report_id: report_id
28
+ aug_id: aug_id,
29
+ report_id: report_id
29
30
  @serializer = Rookout::Processor::NamespaceSerializer2.new
30
- @aug_report_message.arguments2 = @serializer.dump arguments
31
+ @aug_report_message.arguments2 = @serializer.dump arguments, true
31
32
  @serializer.string_cache.each { |key, value| @aug_report_message.strings_cache[key] = value }
32
33
  @envelope = wrap_in_envelope @aug_report_message
33
34
  @aug_report_message = nil
@@ -44,6 +45,7 @@ end
44
45
 
45
46
  class EnvelopeWrapper < EnvelopeWrapperBase
46
47
  def initialize message
48
+ super()
47
49
  @envelope = wrap_in_envelope message
48
50
  end
49
51
 
@@ -42,7 +42,7 @@ module Rookout
42
42
  link_contents = File.read link_path
43
43
 
44
44
  if link_contents.start_with? "ref:"
45
- next_link = (link_contents.split " ")[1].strip
45
+ next_link = link_contents.split[1].strip
46
46
  follow_sym_links root, next_link
47
47
  else
48
48
  link_contents.strip
@@ -56,7 +56,8 @@ module Rookout
56
56
  scm: @scm_info
57
57
  end
58
58
 
59
- attr_accessor :agent_id, :labels
59
+ attr_accessor :agent_id
60
+ attr_accessor :labels
60
61
 
61
62
  private
62
63
 
@@ -42,7 +42,8 @@ module Rookout
42
42
  @closing = false
43
43
  end
44
44
 
45
- attr_accessor :agent_id, :agent_com
45
+ attr_accessor :agent_id
46
+ attr_accessor :agent_com
46
47
 
47
48
  def close
48
49
  @closing = true
@@ -86,13 +87,17 @@ module Rookout
86
87
  if arguments.nil? || arguments.call_method("size", "") == 0
87
88
  protobuf_arguments = nil
88
89
  else
89
- protobuf_arguments = Processor::NamespaceSerializer.dump arguments
90
+ protobuf_arguments = Processor::NamespaceSerializer.dump arguments, true
90
91
  end
91
92
 
92
- envelope_wrapper = EnvelopeWrapper.new(Com::Rookout::AugReportMessage.new(agent_id: @agent_id,
93
- aug_id: aug_id,
94
- report_id: report_id,
95
- arguments: protobuf_arguments))
93
+ envelope_wrapper = EnvelopeWrapper.new(
94
+ Com::Rookout::AugReportMessage.new(
95
+ agent_id: @agent_id,
96
+ aug_id: aug_id,
97
+ report_id: report_id,
98
+ arguments: protobuf_arguments
99
+ )
100
+ )
96
101
  end
97
102
 
98
103
  @agent_com.add envelope_wrapper
@@ -123,7 +128,8 @@ module Rookout
123
128
  protobuf_arguments = nil
124
129
  else
125
130
  protobuf_arguments = Processor::NamespaceSerializer.dump(
126
- Processor::Namespaces::RubyObjectNamespace.new(arguments)
131
+ Processor::Namespaces::RubyObjectNamespace.new(arguments),
132
+ true
127
133
  )
128
134
  end
129
135
 
@@ -1,3 +1,3 @@
1
1
  module Rookout
2
- COMMIT = "2c51b13711b7b94b1a58728d299d8981dc76e18f".freeze
2
+ COMMIT = "b34115d35e36dcb568599cc5279fc7e934619ef5".freeze
3
3
  end
@@ -6,21 +6,26 @@ module Rookout
6
6
  # Magic to allow for module variables to be easily accessible
7
7
  class << self
8
8
  attr_accessor :debug
9
+
9
10
  Rookout::Config.debug = false
10
11
 
11
- attr_accessor :logger_filename, :logger_log_to_stderr, :logger_log_level
12
+ attr_accessor :logger_filename
13
+ attr_accessor :logger_log_to_stderr
14
+ attr_accessor :logger_log_level
15
+
12
16
  Rookout::Config.logger_filename = "rookout/ruby-rook.log".freeze
13
17
  Rookout::Config.logger_log_to_stderr = false
14
18
  Rookout::Config.logger_log_level = :info
15
19
 
16
- attr_accessor :agent_com_configuration_command_thread_name,
17
- :agent_com_max_message_limit,
18
- :agent_com_max_queue_messages_length,
19
- :agent_com_timeout,
20
- :agent_com_ping_interval,
21
- :agent_com_ping_timeout,
22
- :agent_com_flush_timeout,
23
- :agent_com_max_queued_messages
20
+ attr_accessor :agent_com_configuration_command_thread_name
21
+ attr_accessor :agent_com_max_message_limit
22
+ attr_accessor :agent_com_max_queue_messages_length
23
+ attr_accessor :agent_com_timeout
24
+ attr_accessor :agent_com_ping_interval
25
+ attr_accessor :agent_com_ping_timeout
26
+ attr_accessor :agent_com_flush_timeout
27
+ attr_accessor :agent_com_max_queued_messages
28
+
24
29
  Rookout::Config.agent_com_max_message_limit = 1024 * 1024
25
30
  Rookout::Config.agent_com_max_queue_messages_length = 15 * 1024 * 1024
26
31
  Rookout::Config.agent_com_timeout = 3
@@ -29,47 +34,80 @@ module Rookout
29
34
  Rookout::Config.agent_com_flush_timeout = 3
30
35
  Rookout::Config.agent_com_max_queued_messages = 100
31
36
 
32
- attr_accessor :backoff_factor, :backoff_reset_time, :backoff_max_time
37
+ attr_accessor :backoff_factor
38
+ attr_accessor :backoff_reset_time
39
+ attr_accessor :backoff_max_time
40
+
33
41
  Rookout::Config.backoff_factor = 0.2
34
42
  Rookout::Config.backoff_max_time = 60
35
43
  Rookout::Config.backoff_reset_time = 3 * 60.0
36
44
 
37
- attr_accessor :output_max_status_updates,
38
- :output_max_aug_messages,
39
- :output_max_log_items,
40
- :output_bucket_refresh_rate
45
+ attr_accessor :output_max_status_updates
46
+ attr_accessor :output_max_aug_messages
47
+ attr_accessor :output_max_log_items
48
+ attr_accessor :output_bucket_refresh_rate
49
+
41
50
  Rookout::Config.output_max_status_updates = 200
42
51
  Rookout::Config.output_max_aug_messages = 100
43
52
  Rookout::Config.output_max_log_items = 200
44
53
  Rookout::Config.output_bucket_refresh_rate = 10
45
54
 
46
55
  attr_accessor :instrumentation_max_aug_time
56
+
47
57
  Rookout::Config.instrumentation_max_aug_time = 400
48
58
 
49
- attr_accessor :user_git_commit, :user_git_origin
59
+ attr_accessor :user_git_commit
60
+ attr_accessor :user_git_origin
61
+
50
62
  Rookout::Config.user_git_commit = nil
51
63
  Rookout::Config.user_git_origin = nil
52
64
 
53
- attr_accessor :rookout_version, :rookout_commit
65
+ attr_accessor :rookout_version
66
+ attr_accessor :rookout_commit
67
+
54
68
  Rookout::Config.rookout_version = Rookout::VERSION
55
69
  Rookout::Config.rookout_commit = Rookout::COMMIT
56
70
 
57
71
  attr_accessor :protobuf_version2
72
+
58
73
  Rookout::Config.protobuf_version2 = false
59
74
 
60
75
  attr_accessor :true_values
76
+
61
77
  Rookout::Config.true_values = ["y", "Y", "yes", "Yes", "YES", "true", "True", "TRUE", "1"]
62
78
 
79
+ attr_accessor :global_rate_limit
80
+
81
+ Rookout::Config.global_rate_limit = nil
63
82
 
64
83
  def update_config configuration
84
+ update_var2_config configuration
85
+ update_global_rate_limit_config configuration
86
+ end
87
+
88
+ def update_var2_config configuration
65
89
  is_config_proto2 = configuration["RUBY_PROTOBUF_VERSION_2"]
66
90
  return if is_config_proto2.nil?
67
- is_env_proto2 = ENV["PROTOBUF_VERSION_2"]
91
+ is_env_proto2 = ENV["ROOKOUT_Protobuf_Version2"]
68
92
  if is_env_proto2.nil?
69
93
  @protobuf_version2 = true if @true_values.include? is_config_proto2
70
94
  elsif @true_values.include? is_env_proto2
95
+ Logger.instance.debug "ROOKOUT_Protobuf_Version2 env is preset: #{is_env_proto2}"
71
96
  @protobuf_version2 = true
72
97
  end
98
+ Logger.instance.info "Updating ROOKOUT_Protobuf_Version2 value to: #{@protobuf_version2}"
99
+ end
100
+
101
+ def update_global_rate_limit_config configuration
102
+ global_rate_limit = ENV["ROOKOUT_GLOBAL_RATE_LIMIT"]
103
+ if global_rate_limit.nil?
104
+ global_rate_limit = configuration["RUBY_GLOBAL_RATE_LIMIT"]
105
+ end
106
+
107
+ return if global_rate_limit.nil?
108
+
109
+ @global_rate_limit = global_rate_limit
110
+ Logger.instance.info "Updating global rate limit to: #{global_rate_limit}"
73
111
  end
74
112
  end
75
113
  end
@@ -11,9 +11,6 @@ module Rookout
11
11
  end
12
12
 
13
13
  class RookInterfaceException < ToolException
14
- def initialize message
15
- super message
16
- end
17
14
  end
18
15
 
19
16
  class RookVersionNotSupported < ToolException
@@ -92,8 +89,8 @@ module Rookout
92
89
  class RookMessageSizeExceeded < ToolException
93
90
  def initialize message_size, max_message_size
94
91
  super "Message size of #{message_size} exceeds max size limit of #{max_message_size}. " \
95
- "Change the depth of collection or change the default by setting ROOKOUT_MAX_MESSAGE_SIZE " \
96
- "as environment variable or system property",
92
+ "Change the depth of collection or change the default by setting ROOKOUT_MAX_MESSAGE_SIZE " \
93
+ "as environment variable or system property",
97
94
  { "message_size" => message_size, "max_message_size" => max_message_size }
98
95
  end
99
96
  end
@@ -101,7 +98,7 @@ module Rookout
101
98
  class RookRuleRateLimited < ToolException
102
99
  def initialize
103
100
  super "Breakpoint was disabled due to rate-limiting. " \
104
- "For more information: https://docs.rookout.com/docs/breakpoints-tasks.html#rate-limiting"
101
+ "For more information: https://docs.rookout.com/docs/breakpoints-tasks.html#rate-limiting"
105
102
  end
106
103
  end
107
104
 
@@ -139,9 +136,6 @@ module Rookout
139
136
  end
140
137
 
141
138
  class RookInvalidOptions < ToolException
142
- def initialize description
143
- super description
144
- end
145
139
  end
146
140
 
147
141
  class RookInvalidLabel < ToolException
@@ -220,6 +214,15 @@ module Rookout
220
214
  end
221
215
  end
222
216
 
217
+ class RookInvalidRateLimitConfiguration < ToolException
218
+ def initialize config
219
+ super "Invalid rate limit configuration: #{config}",
220
+ {
221
+ "rate_limit_config" => config
222
+ }
223
+ end
224
+ end
225
+
223
226
  class RookUnsupportedLiveLogger < ToolException
224
227
  def initialize
225
228
  super "Live Logger is not supported. Try using Rookout Live Debugger instead."
@@ -14,7 +14,7 @@ module Rookout
14
14
 
15
15
  def print_debug_messages
16
16
  puts "[Rookout] Running in debug mode"
17
- puts "[Rookout] Rookout SDK for ruby: " + Config.rookout_version
17
+ puts "[Rookout] Rookout SDK for ruby: #{Config.rookout_version}"
18
18
  end
19
19
 
20
20
  def start options = {}
@@ -36,16 +36,16 @@ module Rookout
36
36
  rook.connect(**@start_options)
37
37
  rescue LoadError
38
38
  raise if throw_errors
39
- STDERR.puts "[Rookout] Failed to load Rookout. Please make sure to force build native extensions by setting" \
40
- "'bundle config force_ruby_platform true'"
39
+ $stderr.puts "[Rookout] Failed to load Rookout. Please make sure to force build native extensions by setting" \
40
+ "'bundle config force_ruby_platform true'"
41
41
  rescue RookMissingToken, RookInvalidToken, RookInvalidOptions, RookVersionNotSupported, RookBadProtobuf => e
42
42
  raise if throw_errors
43
- STDERR.puts "[Rookout] Failed to start Rookout: #{e.message}"
43
+ $stderr.puts "[Rookout] Failed to start Rookout: #{e.message}"
44
44
  rescue RookCommunicationException => e
45
45
  raise if throw_errors
46
- Logger.instance.warning "[Rookout] " + e.message
46
+ Logger.instance.warning "[Rookout] #{e.message}"
47
47
  rescue Exception => e
48
- STDERR.puts e.full_message if Config.debug
48
+ $stderr.puts e.full_message if Config.debug
49
49
  raise if throw_errors
50
50
  end
51
51
  end
@@ -82,12 +82,13 @@ module Rookout
82
82
  # Only test alpine
83
83
  return unless File.exist? "/etc/alpine-release"
84
84
 
85
+ # Make sure protobuf is built from source
85
86
  protobuf = Gem::Specification.find_by_path "google/protobuf"
86
- STDERR.puts RookBadProtobuf.new.message if protobuf.nil?
87
+ $stderr.puts RookBadProtobuf.new.message if protobuf.nil?
87
88
  return unless protobuf.platform != "ruby"
88
89
 
89
90
  error = RookBadProtobufPlatform.new protobuf.platform
90
- STDERR.puts error.message
91
+ $stderr.puts error.message
91
92
  end
92
93
 
93
94
  def configure_globals options