Skip to content

Instantly share code, notes, and snippets.

@oldratlee
Last active December 28, 2015 00:18
Show Gist options
  • Save oldratlee/7411901 to your computer and use it in GitHub Desktop.
Save oldratlee/7411901 to your computer and use it in GitHub Desktop.
BTrace, MethodTracer
import com.sun.btrace.AnyType;
import com.sun.btrace.annotations.Kind;
import com.sun.btrace.annotations.Location;
import com.sun.btrace.annotations.OnMethod;
import com.sun.btrace.annotations.ProbeMethodName;
import static com.sun.btrace.BTraceUtils.print;
import static com.sun.btrace.BTraceUtils.printArray;
/*
<dependency>
<groupId>com.sun.tools.btrace</groupId>
<artifactId>btrace-boot</artifactId>
<version>1.2.3</version>
</dependency>
*/
/**
* @author ding.lid
*/
public class MethodTracer {
@OnMethod(
clazz = "com.xx.Foo",
method = "/put|decr|delete|cas/",
location = @Location(Kind.ENTRY)
)
public static void anyWrite(@ProbeMethodName String pmn, AnyType[] args) {
print(pmn);
print(" - ");
printArray(args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment