基本信息
源码名称:接口调用计数器(spring-aop)
源码大小:0.06M
文件格式:.zip
开发语言:Java
更新时间:2021-10-28
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

简单得接口调用计数器

非侵入式接口信息计数 切面处


@Around(value = "@annotation(metrics)") public void interceptMetrics(ProceedingJoinPoint proceedingJoinPoint, Metrics metrics) throws Throwable { //根据注解参数 决定是否开启监听  以指定的频率统计数据并输出结果  if (metrics.showAllMessageByTimeUnit()) { if (!isShow) {
            startRepeatedReport(60, TimeUnit.SECONDS);  } isShow = true;  }

    Signature signature = proceedingJoinPoint.getSignature();  MethodSignature methodSignature = (MethodSignature) signature;  Method method = methodSignature.getMethod();  String declaringTypeName = signature.getDeclaringTypeName();  String methodName = method.getName();  String allTypeMethodName = declaringTypeName "."  methodName;  //前置处理  long startTimestamp = System.currentTimeMillis();  //执行逻辑  proceedingJoinPoint.proceed();  //后置处理  long respTime = System.currentTimeMillis() - startTimestamp;   //记录接口响应时间  recordResponseTime(allTypeMethodName, respTime);  //记录接口请求时间  recordRequestTimestamp(allTypeMethodName, startTimestamp);   //根据注解参数决定是否 输出单次接口信息  if (metrics.realtimeDisplay() == true) {
        System.out.println(getAllTypeMsg());  }
}