btrace-doc
2019-03-25 本文已影响0人
泠泉
demo 动态获取传入参数
- 源码
@RestController
@RequestMapping("/ch4")
public class Ch4Controller{
@RequestMapping("/arg1")
public String arg1(@RequestParam("name")String name){
return "hello,"+name;
}
}
- btrace脚本(PrintArgSimple.java)
import com.sun.btrace.AnyType;
import com.sun.btrace.annotations.*;
import static com.sun.btrace.BTraceUtils.*;
@BTrace
public class PrintArgSimple{
@OnMethod(
clazz="com.xxx.monitor_tuning.cp4.ch4Controller",
method="arg1",
location=@Location(Kind.ENTRY)
)
public static void anyRead(@ProbeClassName String pcn,
@ProbeMethodName String pmn,
AnyType[] args){
BTraceUtils.printArray(args);
BTraceUtils.printArray(pcn+","+pmn);
BTraceUtils.printArray();
}
}