rookout 0.1.44 → 0.1.46

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: 0233712f50c0fe5e94c8288b73ee96a07da9bb1692cc553ac83692a10655c131
4
- data.tar.gz: b273a8cc02ed25508400b58758c5706f6073a979c7d323316c9957dd4f186d30
3
+ metadata.gz: b59aefa8a8063910a6a7ec3446c7f709a9781468e786993f2b7ae84b47c284cc
4
+ data.tar.gz: 91fc89ae75510ab8a81de5da86a3619c2f17d6a2920aa72d9f718436ac1b7056
5
5
  SHA512:
6
- metadata.gz: afbacca6a3828ebb0e2bda728c072a9515fa6f3003945a9ab5bf972bde564a77dc950224d14bbc58b90aebdef3f505c90b89baf8d916beaca9c3bac3215fdb98
7
- data.tar.gz: bf5c468000ed3dd7e2def2d628acab6540226ade8364a77036a12421ade338ed0106123f4c19cbc9e81c988e624bf50e9e84aa3dec090a17e68c41014390dc06
6
+ metadata.gz: 0b9a998c2f766b42e115e103e92883807c813d9bdb583d6f9eaf148ead19de00d8fd71dae6a98a88dcfdbcd028634ff5de865410911b7ffcae92ff84bf224c20
7
+ data.tar.gz: b5ee7cf8ff1af74a6718d5abfd5d87e56ca7a521d470449abab7d07c525e32fa5f979e7b97553340dfd5a2b35618573ec10f4c2855cfc7ed24ccf5d2495abd07
@@ -114,8 +114,8 @@ module Rookout
114
114
 
115
115
  if @print_on_initial_connection
116
116
  @print_on_initial_connection = false
117
- Utils.quiet_puts "[Rookout] Successfully connected to controller"
118
- Utils.quiet_puts "[Rookout] Rook's ID is #{@agent_id}"
117
+ Utils.quiet_puts "[Rookout] Successfully connected to controller."
118
+ Logger.instance.debug "[Rookout] Agent ID is #{@agent_id}"
119
119
  end
120
120
  Logger.instance.debug "WebSocket connected successfully"
121
121
  Logger.instance.info "Finished initialization"
@@ -29,19 +29,26 @@ class Variant2EnvelopeWrapper < EnvelopeWrapperBase
29
29
  report_id: report_id
30
30
  @serializer = Rookout::Processor::NamespaceSerializer2.new
31
31
  @aug_report_message.arguments2 = @serializer.dump arguments, true
32
- @serializer.string_cache.each do |key, value|
33
- @aug_report_message.strings_cache[key.encode "UTF-8", invalid: :replace, undef: :replace, replace: "?"] = value
34
- end
35
- @envelope = wrap_in_envelope @aug_report_message
36
- @aug_report_message = nil
32
+
33
+ @estimated_length = @serializer.estimated_pending_bytes
34
+ @envelope = nil
37
35
  end
38
36
 
39
37
  def envelope
38
+ if @envelope.nil?
39
+ @serializer.string_cache.each do |key, value|
40
+ @aug_report_message.strings_cache[key.encode "UTF-8", invalid: :replace, undef: :replace, replace: "?"] = value
41
+ end
42
+ @envelope = wrap_in_envelope @aug_report_message
43
+
44
+ @serializer = nil
45
+ @aug_report_message = nil
46
+ end
40
47
  @envelope
41
48
  end
42
49
 
43
50
  def calculate_size
44
- @envelope.length
51
+ @estimated_length
45
52
  end
46
53
  end
47
54
 
@@ -1,3 +1,3 @@
1
1
  module Rookout
2
- COMMIT = "426414a386441285302fbe4424892b2a98989af5".freeze
2
+ COMMIT = "ec556ada7fc1b5196406db4ed39b386974440d91".freeze
3
3
  end
@@ -16,6 +16,13 @@ module Rookout
16
16
  MASH = nil
17
17
  end
18
18
 
19
+ begin
20
+ require "active_support/core_ext/hash/indifferent_access"
21
+ HASH_WITH_INDIFFERENT_ACCESS = ActiveSupport::HashWithIndifferentAccess
22
+ rescue LoadError
23
+ HASH_WITH_INDIFFERENT_ACCESS = nil
24
+ end
25
+
19
26
  def initialize
20
27
  @string_cache = {}
21
28
  @estimated_pending_bytes = 0
@@ -37,10 +44,12 @@ module Rookout
37
44
 
38
45
  def dump_variant_type variant, type
39
46
  variant.variant_type_max_depth = type << 1
47
+ @estimated_pending_bytes += 2 # Field header + short number
40
48
  end
41
49
 
42
50
  def dump_variant_type_max_depth variant, type
43
51
  variant.variant_type_max_depth = (type << 1) | 1
52
+ @estimated_pending_bytes += 2 # Field header + short number
44
53
  end
45
54
 
46
55
  def dump namespace, log_errors
@@ -57,6 +66,7 @@ module Rookout
57
66
  rescue StandardError => e
58
67
  message = "Failed to serialize namespace"
59
68
  variant = Com::Rookout::Variant2.new
69
+ @estimated_pending_bytes = 0
60
70
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_ERROR
61
71
 
62
72
  if log_errors
@@ -77,6 +87,7 @@ module Rookout
77
87
  rescue StandardError => e
78
88
  message = "Failed to serialize object"
79
89
  variant = Com::Rookout::Variant2.new
90
+ @estimated_pending_bytes = 0
80
91
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_ERROR
81
92
 
82
93
  if log_object_errors
@@ -105,7 +116,8 @@ module Rookout
105
116
  dump_time obj, variant
106
117
  elsif obj.class == Array
107
118
  dump_array obj, variant, current_depth, config, log_object_errors
108
- elsif obj.class == Hash || (!MASH.nil? && obj.is_a?(MASH))
119
+ elsif obj.class == Hash || (!MASH.nil? && obj.is_a?(MASH)) ||
120
+ (!HASH_WITH_INDIFFERENT_ACCESS.nil? && obj.is_a?(HASH_WITH_INDIFFERENT_ACCESS))
109
121
  dump_hash obj, variant, current_depth, config, log_object_errors
110
122
  elsif obj.is_a? Exception
111
123
  dump_exception obj, variant, current_depth, config, log_object_errors
@@ -137,20 +149,24 @@ module Rookout
137
149
  when true
138
150
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_LONG
139
151
  variant.long_value = 1
152
+ @estimated_pending_bytes += 2 # Header + short number
140
153
  when false
141
154
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_LONG
142
155
  variant.long_value = 0
156
+ @estimated_pending_bytes += 2 # Header + short number
143
157
  when Integer
144
158
  dump_integer obj, variant
145
159
  when Float
146
160
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_DOUBLE
147
161
  variant.double_value = obj.to_f
162
+ @estimated_pending_bytes += 7 # Header + 64 bit float
148
163
  when BigDecimal
149
164
  dump_string obj.to_s, variant, config # TODO: NS: This might cut the decimal value, is that ok?
150
165
  when Complex
151
166
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_COMPLEX
152
167
  variant.complex_value = Com::Rookout::Variant::Complex.new real: obj.real.to_f,
153
168
  imaginary: obj.imaginary.to_f
169
+ @estimated_pending_bytes += 8 # Large header + size + (header + 64 bit float) * 2
154
170
  else
155
171
  raise Exceptions::RookClassCannotBeSerialized.new(obj.class, "Unknown Numeric Type")
156
172
  end
@@ -165,6 +181,7 @@ module Rookout
165
181
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_LARGE_INT
166
182
  variant.bytes_index_in_cache = get_string_index_in_cache obj.to_s
167
183
  end
184
+ @estimated_pending_bytes += 3 # Header + number
168
185
  end
169
186
 
170
187
  def dump_string obj, variant, config
@@ -178,16 +195,20 @@ module Rookout
178
195
  variant.original_size = obj.length
179
196
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_STRING
180
197
  variant.bytes_index_in_cache = get_string_index_in_cache final_obj
198
+ @estimated_pending_bytes += 6 # Header + number + header + number
181
199
  end
182
200
 
183
201
  def dump_time obj, variant
184
202
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_TIME
185
203
  variant.time_value = Google::Protobuf::Timestamp.new
186
204
  variant.time_value.from_time obj
205
+
206
+ @estimated_pending_bytes += 16 # Header + size + (header + 32 bit number + header + 64 bit number)
187
207
  end
188
208
 
189
209
  def dump_array obj, variant, current_depth, config, log_object_errors
190
210
  variant.original_size = obj.length
211
+ @estimated_pending_bytes += 3 # Header + number
191
212
 
192
213
  weighted_children_depth = current_depth + 1
193
214
  if weighted_children_depth <= config.max_collection_depth
@@ -195,6 +216,7 @@ module Rookout
195
216
  obj.each_with_index do |value, index|
196
217
  break if index >= config.max_width
197
218
  variant.collection_values << dump_raw_object(value, weighted_children_depth, config, log_object_errors)
219
+ @estimated_pending_bytes += 3 # Header + size
198
220
  end
199
221
  else
200
222
  dump_variant_type_max_depth variant, Com::Rookout::Variant::Type::VARIANT_LIST
@@ -211,6 +233,7 @@ module Rookout
211
233
  break if index >= config.max_width
212
234
  variant.collection_keys << dump_raw_object(key, weighted_children_depth, config, log_object_errors)
213
235
  variant.collection_values << dump_raw_object(value, weighted_children_depth, config, log_object_errors)
236
+ @estimated_pending_bytes += 6 # Header + size + header + size
214
237
  end
215
238
  else
216
239
  dump_variant_type_max_depth variant, Com::Rookout::Variant::Type::VARIANT_MAP
@@ -221,12 +244,15 @@ module Rookout
221
244
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_OBJECT
222
245
  variant.attribute_names_in_cache << get_string_index_in_cache("message")
223
246
  variant.attribute_values << dump_raw_object(obj.message, current_depth + 1, config, log_object_errors)
247
+ @estimated_pending_bytes += 6 # Header + number + header + size
224
248
 
225
249
  variant.attribute_names_in_cache << get_string_index_in_cache("cause")
226
250
  variant.attribute_values << dump_raw_object(obj.cause, current_depth + 1, config, log_object_errors)
251
+ @estimated_pending_bytes += 6 # Header + number + header + size
227
252
 
228
253
  variant.attribute_names_in_cache << get_string_index_in_cache("backtrace")
229
254
  variant.attribute_values << dump_raw_object(obj.backtrace, current_depth + 1, config, log_object_errors)
255
+ @estimated_pending_bytes += 6 # Header + number + header + size
230
256
  end
231
257
 
232
258
  def dump_code_object obj, variant
@@ -247,6 +273,9 @@ module Rookout
247
273
  variant.code_values << Com::Rookout::Variant::CodeObject.new(name: name,
248
274
  filename: source_location[0],
249
275
  lineno: source_location[1])
276
+ # NOTE: This size is probably less, in Python we use the optional fields of CodeObject and in Ruby we don't,
277
+ # but it is better to estimate more
278
+ @estimated_pending_bytes += 14 # Header + size + (header + number) * 4
250
279
  end
251
280
 
252
281
  def dump_user_class variant, obj, current_depth, config, log_object_errors
@@ -258,6 +287,7 @@ module Rookout
258
287
  raw_value = obj.instance_variable_get name
259
288
  variant.attribute_names_in_cache << get_string_index_in_cache(name.to_s)
260
289
  variant.attribute_values << dump_raw_object(raw_value, weighted_children_depth, config, log_object_errors)
290
+ @estimated_pending_bytes += 6 # Header + number + header + number
261
291
  end
262
292
  else
263
293
  dump_variant_type_max_depth variant, Com::Rookout::Variant::Type::VARIANT_OBJECT
@@ -273,6 +303,8 @@ module Rookout
273
303
  variant.attribute_values << dump(value, log_errors)
274
304
  end
275
305
 
306
+ @estimated_pending_bytes += 4 # One number (packed field), One header + length
307
+
276
308
  variant
277
309
  end
278
310
 
@@ -289,6 +321,8 @@ module Rookout
289
321
  lineno: frame.source_location[1],
290
322
  name: frame.eval("__method__").to_s
291
323
  variant.code_values << code_object
324
+ # See dump_code_object
325
+ @estimated_pending_bytes += 14 # Header + size + (header + number) * 4
292
326
  end
293
327
  variant
294
328
  end
@@ -1,3 +1,3 @@
1
1
  module Rookout
2
- VERSION = "0.1.44".freeze
2
+ VERSION = "0.1.46".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.44
4
+ version: 0.1.46
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-10-04 00:00:00.000000000 Z
11
+ date: 2022-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: binding_of_caller