-
Notifications
You must be signed in to change notification settings - Fork 955
Trace Scripts
Jaroslav Bachorik edited this page Jul 12, 2026
·
4 revisions
A trace script defines where BTrace instruments a target JVM and what it should report. Scripts are ordinary Java source with BTrace annotations.
@BTrace
public class SlowMethods {
@OnMethod(clazz = "com.example.OrderService", method = "*")
public static void onEntry(@ProbeMethodName String method) {
println(method);
}
}Stable 2.2.x probes use org.openjdk.btrace packages.
Common locations include method entry, return, error, calls, field access, timers, and lifecycle events. See the BTrace annotations page for the supported annotations and arguments.
BTrace verifies probes before submission and restricts what injected code can do. Keep probes narrow, prefer thresholds and sampling on hot paths, and detach when the question is answered. See the stable source documentation.
For more examples, use the stable-release documentation.