1,基于标签的UMP log记录切面.
该切面会针对所有打了@UmpProfile标签的方法织入记录Ump log的逻辑
@Component
@Aspect
public class LogAspect {
@Value("${app.name}")
private String appName;
@Around("@annotation(com.hqj.test.UmpProfile) && execution(* *(..))")
public Object log(ProceedingJoinPoint joinPoint) throws Throwable {
Object result;
String key = joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName();
CallerInfo info = Profiler.registerInfo(key, appName, false, true);
try{
result = joinPoint.proceed();
}catch(Throwable e){
Profiler.functionError(info);
throw e;
}finally {
Profiler.registerInfoEnd(info);
}
return result;
}
}