29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/scout_apm/utils/marshal_logging.rb', line 29
def dive
to_investigate = [InstanceVar.new('Root', @base_obj, nil)]
max_to_check = 10000
checked = 0
while (var = to_investigate.shift)
checked += 1
if checked > max_to_check
return "Limiting Checks (max = #{max_to_check})"
end
obj = var.obj
if offending_hash?(obj)
return "Found undumpable object: #{var.history}"
end
if !dumps?(obj)
if obj.is_a? Hash
keys = obj.keys
keys.each do |key|
to_investigate.push(
InstanceVar.new(key.to_s, obj[key], var)
)
end
elsif obj.is_a? Array
obj.each_with_index do |value, idx|
to_investigate.push(
InstanceVar.new("Index #{idx}", value, var)
)
end
else
symbols = obj.instance_variables
if !symbols.any?
return "Found undumpable object: #{var.history}"
end
symbols.each do |sym|
to_investigate.push(
InstanceVar.new(sym, obj.instance_variable_get(sym), var)
)
end
end
end
end
true
end
|