计算rt

@Service
public class AntClientServiceImpl implements AntClientService {
    private static final Logger logger = LoggerFactory.getLogger(AntClientServiceImpl.class);

    @Override
    public AntResultDTO<List<ModuleDTO>> buildModule(RemoteModuleQuery query, AntRebuildCallback callback, Object obj) {
        Stopwatch stopwatch = Stopwatch.createStarted();
        AntResultDTO<List<ModuleDTO>> moduleRet = null;
        String status =  "success";
        try {
            moduleRet = AntClient.buildModule(query, VipHomeModuleCallback.INSTANCE, obj);
            if(moduleRet!=null){
                if(!moduleRet.getSuccess()){
                    status = "Failed";
                }
                if(CollectionUtils.isEmpty(moduleRet.getData())){
                    status = "empty";
                }
            }

        }catch(Throwable e){
            status = e.getClass().getSimpleName();
            logger.error(e.getMessage(),e);
            throw e;
        } finally {
            stopwatch.stop();
            logger.info("AntClientLog: rt=[{}] | queryModuleIds = [{}]| status = [{}]", stopwatch.elapsed(TimeUnit.MILLISECONDS), query.getModuleIds(), status);
        }
        return moduleRet;
    }
}
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;

import com.google.common.base.Joiner;
import com.google.common.base.Stopwatch;import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


@Service
public class AntClientServiceImpl implements AntClientService {
    private static final Logger logger = LoggerFactory.getLogger(AntClientServiceImpl.class);

    @Override
    public AntResultDTO<List<ModuleDTO>> buildModule(RemoteModuleQuery query, AntRebuildCallback callback, Object obj) {
        Stopwatch stopwatch = Stopwatch.createStarted();
        AntResultDTO<List<ModuleDTO>> moduleRet = null;
        String status =  "success";
        try {
            moduleRet = AntClient.buildModule(query, VipHomeModuleCallback.INSTANCE, obj);
            if(moduleRet!=null){
                if(!moduleRet.getSuccess()){
                    status = "Failed";
                }
                if(CollectionUtils.isEmpty(moduleRet.getData())){
                    status = "empty";
                }
            }

        }catch(Throwable e){
            status = e.getClass().getSimpleName();
            logger.error(e.getMessage(),e);
            throw e;
        } finally {
            stopwatch.stop();
            SystemInfo systemInfo = ApiContext.getSystemInfo();
            String utdid = "empty";
            if(Objects.nonNull(systemInfo)){
                utdid = systemInfo.getUtdid();
            }

            String moduleIds = "";
            if (CollectionUtils.isNotEmpty(query.getModuleIds())){
                moduleIds = Joiner.on(",").join(query.getModuleIds());
            }
            logger.info("AntClientLog|{}|{}|{}|{}",
                    stopwatch.elapsed(TimeUnit.MILLISECONDS), moduleIds, status, utdid);
        }
        return moduleRet;
    }
}
原文地址:https://www.cnblogs.com/iwangzheng/p/7358262.html