Generate Pre-populated Call Graphs (C++ Only)

The previous section describes instrumenting your C/C++ application by calling the instrumentation methods in your code. However, if you do not have the option of modifying your source code, you can generate call graphs that are populated with data from sources such as log files.

To generate a pre-populated call graph:

  1. Create the root of the call graph by instantiating a CallGraph class.
    The following example demonstrates a CallGraph:
    • bt: The business transaction.
    • class_name: The name of the class that contains the root of the call graph.
    • method_name: The name of the method that represents the root of the call graph.
    • file_path: The file path to the class.
    • line_number: The line number of the method.
    • time_msec: The time taken by this frame (method) in milliseconds.
    • frame_type: The type of the frame (the language for the method). Currently, APPD_FRAME_TYPE_CPP is the only option.
    appd::sdk::CallGraph callGraph(bt, "Class1", "main", "/src/file1.cc", 276, 100, APPD_FRAME_TYPE_CPP); 
  2. Create the call graph tree by calling add_child on the root and on any of the added children:
    callGraph.root() .add_child("Class2", "method1", "/src/file2.cc"), 101, 40, APPD_FRAME_TYPE_CPP) .add_child("Class2", "method2", "/src/file2.cc"), 523, 30, APPD_FRAME_TYPE_CPP); auto& cge1 = callGraph.root() .add_child("Class3", "method1", "/src/file3.cc"), 27, 30, APPD_FRAME_TYPE_CPP); cge1.add_child("Class3", "method2", "/src/file3.cc"), 430, 15, APPD_FRAME_TYPE_CPP);
  3. Call add_to_snapshot on the call graph.
    For this to work, the business transaction must be snapshotting.
    callGraph.add_to_snapshot();