lumitrace

Lumitrace

Lumitrace instruments Ruby source code at load time, records expression results, and renders an HTML view that overlays recorded values on your code. It is designed for quick, local “what happened here?” inspection during test runs or scripts.

How It Works

Lumitrace hooks RubyVM::InstructionSequence.translate (when available) to rewrite files at require-time. It records expression results and renders an HTML view that shows them inline. Only the last N values per expression are kept to avoid huge output.

Usage

CLI

Run a script and emit text output (default):

lumitrace path/to/entry.rb

Run another command via exec:

lumitrace exec rake test

Emit HTML output:

lumitrace -h path/to/entry.rb

Limit the number of recorded values per expression (defaults to 3):

LUMITRACE_MAX_SAMPLES=5 lumitrace path/to/entry.rb

Write JSON output explicitly:

lumitrace -j path/to/entry.rb
lumitrace --json=out/lumitrace_recorded.json path/to/entry.rb

Restrict to specific line ranges:

lumitrace --range path/to/entry.rb:10-20,30-35 path/to/entry.rb

Show AI/human help:

lumitrace help
lumitrace help --format json
lumitrace schema --format json

AI-oriented usage guide (Japanese):

Library

Enable instrumentation and HTML output at exit:

require "lumitrace"
Lumitrace.enable!

Enable only for diff ranges (current file):

require "lumitrace/enable_git_diff"

If you want to enable via a single require:

require "lumitrace/enable"

Output

JSON event entries always include types (type-name => count).

{
  "file": "/abs/path/app.rb",
  "start_line": 10,
  "start_col": 2,
  "end_line": 10,
  "end_col": 9,
  "kind": "expr",
  "types": { "Integer": 3, "NilClass": 1 },
  "total": 4
}

Environment Variables

Notes And Limitations

Development

Install dependencies:

bundle install

Run the CLI locally:

lumitrace path/to/entry.rb