package com.tzld.piaoquan.recommend.server.grpcservice;

import com.tzld.piaoquan.recommend.server.util.TraceUtils;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @author dyp
 */
@Aspect
@Component
@Slf4j
public class GrpcAspect {

    @Around("execution(* com.tzld.piaoquan.recommend.server.grpcservice.*GrpcService.*(..))")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        TraceUtils.setMDC();
//
//        String className = pjp.getTarget().getClass().getSimpleName();
//        MethodSignature signature = (MethodSignature) pjp.getSignature();
//        Stopwatch stopwatch = Stopwatch.createStarted();
        Object result = pjp.proceed();

        TraceUtils.removeMDC();
        return result;
    }
}
