Elide can attach GraalVM Insight scripts that observe guest execution without modifying your program. Insight scripts hook into source loading and execution events through a global insight object.
Attaching a script
The repeatable --insights <FILE> global flag attaches one or more Insight
scripts. The script language is selected from its extension: JavaScript
(.js / .cjs / .mjs), TypeScript (.ts / .mts / .cts), or Python
(.py). Because --insights is a global flag, it applies to any run form — a
top-level source file, the run subcommand, or a --snippet — not only run:
elide --insights trace.js run app.ts # attach to `run`
elide --insights trace.py app.mjs # top-level run, Python insight script
Attaching a class
The --insights global option can also be used when running a JVM code. In such
scheme one can also use a JavaScript (as described earlier)
or one can write a Java/Kotlin class against JVM Insight API. In such case one
would use the class: prefix as an argument to the --insights option:
elide run --insights=class:pkg.of.a.JvmInsightClazz
The insight global
Inside an Insight script, the insight object registers observers on guest execution — for example on source load, function enter / return, and expression watch points — as defined by the GraalVM Insight API. This lets a script trace calls, collect timing, or inspect values as the guest runs.
See also
- GraalVM Insight manual: https://www.graalvm.org/tools/graalvm-insight/