-
Notifications
You must be signed in to change notification settings - Fork 955
Adaptive Instrumentation
Jaroslav Bachorik edited this page Jul 12, 2026
·
3 revisions
BTrace can gate probe handlers by instrumentation level. This lets a probe stay lightweight by default and enable more detailed handlers only when needed.
Use enableAt = @Level(...) on @OnMethod:
@OnMethod(clazz = "com.example.Service", enableAt = @Level("=0"))
public static void lightHandler() {
count();
}
@OnMethod(clazz = "com.example.Service", enableAt = @Level(">=1"))
public static void detailedHandler() {
println(method);
}Handlers can call:
BTraceUtils.setInstrumentationLevel(1);
int current = BTraceUtils.getInstrumentationLevel();See the stable-release documentation for more information on level expressions, events, and sampling.