0
我有一个Spring MVC Web应用程序,它连接到一个外部Web服务以进行不同的操作。要计算Web请求的服务响应时间,我使用aspectj来记录服务调用。我可以完美记录执行Web服务方法所需的时间。在Spring中使用Aspects来计算方法处理时间
但我想在HTML视图中显示这些响应时间。我无法找到让这个时间价值回到观点的方法。你的想法非常感谢。
以下是我如何使用sl4j将这些时间记录到CSV文件中。
@Around("execution(* backend.channel.ServiceWrapper.*(..))")
public Object logAroundServiceCall(ProceedingJoinPoint joinPoint) throws Throwable
{
StopWatch sw = new StopWatch();
sw.start();
Object returnVal = null;
try
{
returnVal = joinPoint.proceed();
}
catch (Exception e)
{
LOGGER.error(e.getMessage(), e);
}
finally
{
sw.stop();
SERVICE_TIME_LOGGER.info("{},{}", joinPoint.getSignature().getName(), sw.getTotalTimeMillis());
}
return returnVal;
}