rookout 0.1.45 → 0.1.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 444c8c92029ebc2363f554f4fec406a1d7f6b3f90e54e846bc0768e6fbe5c996
4
- data.tar.gz: 827026de861517076758522a6463e309b25ead5571a5ae46c66998aa174fba8a
3
+ metadata.gz: b59aefa8a8063910a6a7ec3446c7f709a9781468e786993f2b7ae84b47c284cc
4
+ data.tar.gz: 91fc89ae75510ab8a81de5da86a3619c2f17d6a2920aa72d9f718436ac1b7056
5
5
  SHA512:
6
- metadata.gz: b656285e0ce9cb3ce0a02baaaa056b27e3e590b0263e899ae1be3955bbd49036fc358e09a57f9f57074fac2b14f71d4e471f6793b07b2c663fb65a7610656b73
7
- data.tar.gz: 33ad61a0b53c7912f8b4529fceeb00c88bb6f38c4b85a523b05b00d8832088eb3e94647cd5b6d1960deedfb12931d162e69eb63b8ce3d45723e558f41ab17c34
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 = "48e26dc9369b92c454ee88b8e9f66735b4d048ce".freeze
2
+ COMMIT = "ec556ada7fc1b5196406db4ed39b386974440d91".freeze
3
3
  end
@@ -44,10 +44,12 @@ module Rookout
44
44
 
45
45
  def dump_variant_type variant, type
46
46
  variant.variant_type_max_depth = type << 1
47
+ @estimated_pending_bytes += 2 # Field header + short number
47
48
  end
48
49
 
49
50
  def dump_variant_type_max_depth variant, type
50
51
  variant.variant_type_max_depth = (type << 1) | 1
52
+ @estimated_pending_bytes += 2 # Field header + short number
51
53
  end
52
54
 
53
55
  def dump namespace, log_errors
@@ -64,6 +66,7 @@ module Rookout
64
66
  rescue StandardError => e
65
67
  message = "Failed to serialize namespace"
66
68
  variant = Com::Rookout::Variant2.new
69
+ @estimated_pending_bytes = 0
67
70
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_ERROR
68
71
 
69
72
  if log_errors
@@ -84,6 +87,7 @@ module Rookout
84
87
  rescue StandardError => e
85
88
  message = "Failed to serialize object"
86
89
  variant = Com::Rookout::Variant2.new
90
+ @estimated_pending_bytes = 0
87
91
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_ERROR
88
92
 
89
93
  if log_object_errors
@@ -145,20 +149,24 @@ module Rookout
145
149
  when true
146
150
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_LONG
147
151
  variant.long_value = 1
152
+ @estimated_pending_bytes += 2 # Header + short number
148
153
  when false
149
154
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_LONG
150
155
  variant.long_value = 0
156
+ @estimated_pending_bytes += 2 # Header + short number
151
157
  when Integer
152
158
  dump_integer obj, variant
153
159
  when Float
154
160
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_DOUBLE
155
161
  variant.double_value = obj.to_f
162
+ @estimated_pending_bytes += 7 # Header + 64 bit float
156
163
  when BigDecimal
157
164
  dump_string obj.to_s, variant, config # TODO: NS: This might cut the decimal value, is that ok?
158
165
  when Complex
159
166
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_COMPLEX
160
167
  variant.complex_value = Com::Rookout::Variant::Complex.new real: obj.real.to_f,
161
168
  imaginary: obj.imaginary.to_f
169
+ @estimated_pending_bytes += 8 # Large header + size + (header + 64 bit float) * 2
162
170
  else
163
171
  raise Exceptions::RookClassCannotBeSerialized.new(obj.class, "Unknown Numeric Type")
164
172
  end
@@ -173,6 +181,7 @@ module Rookout
173
181
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_LARGE_INT
174
182
  variant.bytes_index_in_cache = get_string_index_in_cache obj.to_s
175
183
  end
184
+ @estimated_pending_bytes += 3 # Header + number
176
185
  end
177
186
 
178
187
  def dump_string obj, variant, config
@@ -186,16 +195,20 @@ module Rookout
186
195
  variant.original_size = obj.length
187
196
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_STRING
188
197
  variant.bytes_index_in_cache = get_string_index_in_cache final_obj
198
+ @estimated_pending_bytes += 6 # Header + number + header + number
189
199
  end
190
200
 
191
201
  def dump_time obj, variant
192
202
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_TIME
193
203
  variant.time_value = Google::Protobuf::Timestamp.new
194
204
  variant.time_value.from_time obj
205
+
206
+ @estimated_pending_bytes += 16 # Header + size + (header + 32 bit number + header + 64 bit number)
195
207
  end
196
208
 
197
209
  def dump_array obj, variant, current_depth, config, log_object_errors
198
210
  variant.original_size = obj.length
211
+ @estimated_pending_bytes += 3 # Header + number
199
212
 
200
213
  weighted_children_depth = current_depth + 1
201
214
  if weighted_children_depth <= config.max_collection_depth
@@ -203,6 +216,7 @@ module Rookout
203
216
  obj.each_with_index do |value, index|
204
217
  break if index >= config.max_width
205
218
  variant.collection_values << dump_raw_object(value, weighted_children_depth, config, log_object_errors)
219
+ @estimated_pending_bytes += 3 # Header + size
206
220
  end
207
221
  else
208
222
  dump_variant_type_max_depth variant, Com::Rookout::Variant::Type::VARIANT_LIST
@@ -219,6 +233,7 @@ module Rookout
219
233
  break if index >= config.max_width
220
234
  variant.collection_keys << dump_raw_object(key, weighted_children_depth, config, log_object_errors)
221
235
  variant.collection_values << dump_raw_object(value, weighted_children_depth, config, log_object_errors)
236
+ @estimated_pending_bytes += 6 # Header + size + header + size
222
237
  end
223
238
  else
224
239
  dump_variant_type_max_depth variant, Com::Rookout::Variant::Type::VARIANT_MAP
@@ -229,12 +244,15 @@ module Rookout
229
244
  dump_variant_type variant, Com::Rookout::Variant::Type::VARIANT_OBJECT
230
245
  variant.attribute_names_in_cache << get_string_index_in_cache("message")
231
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
232
248
 
233
249
  variant.attribute_names_in_cache << get_string_index_in_cache("cause")
234
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
235
252
 
236
253
  variant.attribute_names_in_cache << get_string_index_in_cache("backtrace")
237
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
238
256
  end
239
257
 
240
258
  def dump_code_object obj, variant
@@ -255,6 +273,9 @@ module Rookout
255
273
  variant.code_values << Com::Rookout::Variant::CodeObject.new(name: name,
256
274
  filename: source_location[0],
257
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
258
279
  end
259
280
 
260
281
  def dump_user_class variant, obj, current_depth, config, log_object_errors
@@ -266,6 +287,7 @@ module Rookout
266
287
  raw_value = obj.instance_variable_get name
267
288
  variant.attribute_names_in_cache << get_string_index_in_cache(name.to_s)
268
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
269
291
  end
270
292
  else
271
293
  dump_variant_type_max_depth variant, Com::Rookout::Variant::Type::VARIANT_OBJECT
@@ -281,6 +303,8 @@ module Rookout
281
303
  variant.attribute_values << dump(value, log_errors)
282
304
  end
283
305
 
306
+ @estimated_pending_bytes += 4 # One number (packed field), One header + length
307
+
284
308
  variant
285
309
  end
286
310
 
@@ -297,6 +321,8 @@ module Rookout
297
321
  lineno: frame.source_location[1],
298
322
  name: frame.eval("__method__").to_s
299
323
  variant.code_values << code_object
324
+ # See dump_code_object
325
+ @estimated_pending_bytes += 14 # Header + size + (header + number) * 4
300
326
  end
301
327
  variant
302
328
  end
@@ -1,3 +1,3 @@
1
1
  module Rookout
2
- VERSION = "0.1.45".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.45
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-12 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