JbootMetricConterAopInterceptor.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:jboot 作者:
@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {

    EnableMetricCounter annotation = methodInvocation.getThis().getClass().getAnnotation(EnableMetricCounter.class);

    String name = StringUtils.isBlank(annotation.value())
            ? methodInvocation.getThis().getClass().getName() + "." + methodInvocation.getMethod().getName()
            : annotation.value();

    Counter counter = Jboot.me().getMetric().counter(name);
    try {
        counter.inc();
        return methodInvocation.proceed();
    } finally {
        counter.dec();
    }

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号