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.



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

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

#app?Boolean

Returns:

  • (Boolean)


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

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

#calls_only_app_nodes?Boolean

Returns:

  • (Boolean)


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

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

#has_samples?Boolean

Returns:

  • (Boolean)


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

def has_samples?
  samples > 0
end

#inspectObject



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

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