美文网首页
btrace-doc

btrace-doc

作者: 泠泉 | 来源:发表于2019-03-25 18:27 被阅读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();
      }
    }
    

    相关文章

      网友评论

          本文标题:btrace-doc

          本文链接:https://www.haomeiwen.com/subject/kxwbvqtx.html