in codeguru_profiler_agent/model/call_graph_node.py [0:0]
def __init__(self, frame_name, class_name, file_path, line_no, memory_counter=None):
"""
A node represents a given stack frame at a given position in the stack:
* it can have children -- frames that were observed to be on top of this frame in some samples
* it will probably have a parent (except for the root node), but does not keep a reference to it
It also keeps track of how many times (per thread state) this frame was observed in thread stacks across
one or more samples.
:param frame_name: name of the stack frame
:param class_name: name of the class for where the method is sampled; or None if not applicable
:param file_path: the absolute path for the file containing the frame; or None if not applicable
:param line_no: the line_no where we observed this node; or None if not applicable
"""
self.frame_name = frame_name
# For normal usage of class, we are able to extract the class name from solution mentioned on
# https://stackoverflow.com/questions/2203424/python-how-to-retrieve-class-information-from-a-frame-object/2544639#2544639
# Note that this solution relies on the assumption that the class method has taken self as its first argument
self.class_name = class_name
# In well-behaved Python code (not messing with importlib.reload and with dynamically changing the search path),
# the same frame_name will always correspond to the same file. Since we don't really think those use cases are
# common, for now we just assume this is the case and don't check for it
self.file_path = file_path
self.runnable_count = 0
# the start and end of the range of line number where we observed this node
# None is expected for root node and agent duration metric node
self.start_line = line_no
self.end_line = line_no
self.children = ()
self.memory_counter = memory_counter
if memory_counter:
memory_counter.count_create_node(frame_name, file_path, class_name)