Class: ScoutApm::StackprofTreeCollapser::TreeNode

Inherits:
Struct
  • Object
show all
Defined in:
lib/scout_apm/stackprof_tree_collapser.rb

Overview

TreeNode class represents a single node.

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object

Force object_id to be the equality mechanism, rather than struct’s default which delegates to == on each value. That is wrong because we want to be able to dup a node in the tree construction process and not have those compare equal to each other.



84
85
86
# File 'lib/scout_apm/stackprof_tree_collapser.rb', line 84

def ==(other)
  object_id == other.object_id
end

#app?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/scout_apm/stackprof_tree_collapser.rb', line 76

def app?
  @is_app ||= file =~ /^#{ScoutApm::Environment.instance.root}/
end

#calls_only_app_nodes?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/scout_apm/stackprof_tree_collapser.rb', line 94

def calls_only_app_nodes?
  children.all?(&:app?)
end

#has_samples?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/scout_apm/stackprof_tree_collapser.rb', line 98

def has_samples?
  samples > 0
end

#inspectObject



88
89
90
91
92
# File 'lib/scout_apm/stackprof_tree_collapser.rb', line 88

def inspect
  "#{frame_id}: #{name} - ##{samples}\n" +
  "  Parents: #{parents.map{ |(p, w)| "#{p.name}: #{w}"}.join("\n           ") }\n" +
  "  Children: #{children_edges.inspect} \n"
end