Understanding Truffle instrumentation
Truffle provides an Instrumentation API to help build instrumentation and tools for diagnosis, monitoring, and debugging. Truffle also provides a reference implementation called Simple Tool (https://github.com/graalvm/simpletool). Truffle provides a very high-performance instrumentation design. The instrumentation is achieved with the help of probes and tags. The probes are attached to the AST nodes to capture the instrumentation data, and the nodes are identified using tags. Multiple instruments can be attached to the probe. The following figure shows a typical instrumentation:
The preceding figure illustrates how Truffle's Instrument API connects to the AST to collect the various metrics/data. Truffle displaces the original node by inserting a wrapper node and passes the information to the probe node, which can be connected to multiple instruments to collect the data.