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();
}
}
网友评论