Recording

This page summarizes what Metawork records and how it does so.

How recording works

Metawork is instrumented to automatically record the execution of code it interprets as important to you, including code Metawork interprets as user-written and commonly-used framework code.

This table lays out what code is automatically instrumented by Metawork's supercharged language runtimes.

Runtime

Instrumented automatically

Ruby

Rack
Active Job

Node.js

http built-in module

Recording code that is not instrumented automatically

To record code that isn't automatically instrumented by Metawork, use Metawork.record.

Metawork.record takes a string (the name you want to assign to the recorded operation), and then a block (the contents of which are recorded during subsequent runs). Try to put one Metawork.record call as high in the call graph as possible—no need to instrument individual functions.

Metawork.record("Operation Name") { root_method_to_record }
Metawork.record("Operation Name", rootFunctionToRecord);

As an example, here is Metawork.record at work on a portion of each tutorial script provided to you at installation.

def get_started
    # Welcome to Metawork for Ruby!
    #
    # Let's jump into exploring some of the most important aspects of the
    # Metawork experience.
    #
    # You're looking at the recording of the state of the Ruby VM at every
    # method call during the execution of this script.
    #
    # At any time, you can view the frame graph generated by this recording
    # on the left pane title `Frame Graph`.
    #
    # Right now, you're looking at the first frame of this recording, which
    # captured the initial call to `get_started` to kick things off.
    #
    # Below, you can see a call site to the next frame of this recording.
    #
    # Hover over the call site to get a preview of what this call returned,
    # and then click it to open its frame.
    answer_to_everything = foo

    answer_to_everything
end

Metawork.record("Getting Started") { get_started }

puts "🎉 Run `mw open last` and enjoy the magic 🪄"
function getStarted() {
    // Welcome to Metawork for Node.js!
    //
    // Let's jump into exploring some of the most important aspects of the
    // Metawork experience.
    //
    // You're looking at the recording of the state of the Node.js VM (V8) at every
    // function call during the execution of this script.
    //
    // At any time, you can view the frame graph generated by this recording
    // on the left pane titled `Frame Navigator`.
    //
    // Right now, you're looking at the first frame of this recording, which
    // captured the initial call to `getStarted` to kick things off.
    //
    // Below, you can see a call site to the next frame of this recording.
    //
    // Hover over the call site to get a preview of what this call returned,
    // and then click it to open its frame.
    let answerToEverything = foo();

    return answerToEverything;
}

Metawork.record("Getting Started", getStarted);

console.log("🎉 Run `mw open last` and enjoy the magic 🪄");

Data captured by recording

Recorded execution data includes:

Truncation

As part of the analysis process, Metawork may truncate large values (strings, arrays, objects, etc.).

📘

Request automatic instrumentation support

Have a library that you would like automatically recorded by Metawork? Join our Discord server to let us know.