-
Notifications
You must be signed in to change notification settings - Fork 956
BTrace Annotations
Jaroslav Bachorik edited this page Jul 12, 2026
·
15 revisions
Stable probes use org.openjdk.btrace.core.annotations:
import org.openjdk.btrace.core.annotations.*;| Annotation | Purpose |
|---|---|
@BTrace |
Marks a Java probe class. |
@OnMethod |
Instruments a matching class and method. |
@OnTimer |
Runs a handler periodically. |
@OnEvent |
Runs a handler for a client or probe event. |
@OnExit |
Runs when the probe exits. |
@Sampled |
Samples handler execution. |
@Level |
Enables handlers at selected instrumentation levels. |
@ProbeClassName / @ProbeMethodName
|
Injects the matched class or method name. |
@Duration / @Return
|
Injects return duration or value at return/error locations. |
@Self / @TargetInstance
|
Injects the current or called instance where supported. |
For the complete annotation reference, locations, filters, and argument rules, see the stable-release documentation.
@BTrace
public class SlowMethods {
@OnMethod(
clazz = "com.example.OrderService",
method = "*",
location = @Location(Kind.RETURN))
public static void onReturn(
@ProbeMethodName String method, @Duration long duration) {
if (duration > 200_000_000L) {
println(method);
}
}
}