class ScoutApm::Utils::MarshalLogging
Public Class Methods
new(base_obj)
click to toggle source
# File lib/scout_apm/utils/marshal_logging.rb, line 25 def initialize(base_obj) @base_obj = base_obj end
Public Instance Methods
dive()
click to toggle source
# 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
dumps?(obj)
click to toggle source
# File lib/scout_apm/utils/marshal_logging.rb, line 78 def dumps?(obj) Marshal.dump(obj) true rescue TypeError false end
offending_hash?(obj)
click to toggle source
# File lib/scout_apm/utils/marshal_logging.rb, line 85 def offending_hash?(obj) obj.is_a?(Hash) && !obj.default_proc.nil? end