Accompanying article can be found at:
https://www.scoutapm.com/blog/instrumenting-code-using-prism-and-the-ruby-abstract-syntax-tree
An introduction to Prism, the Ruby AST, and using YARV to instrument Ruby code with timing instrumentation.
Part 0. Instruction Sequence
Part 1. Hook
Part 2: Basic Method Swap
Part 3: Basic Method Wrapping
Part 4: Class Method Wrapping