Spring 看点 + WebFlux。预期会有什么行为?
Spring Aspect + WebFlux. What behavior is expected?
我正在尝试创建我的 @Around
注释来制作 Prometheus
指标。
看点:
@Around("@annotation(TimeMetric)")
public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
// duration.startTimer();
Object object = joinPoint.proceed();
// durationTimer.setDuration();
return object;
}
控制器:
@TimeMetric
@GetMapping(path = "")
Mono<SomeResult> health() {
return Mono.just(service.doSomeJob());
}
我的预期行为是:
I will get metrics without execution time service.doSomeJob()
, as I
return Mono
.
但是当我得到结果时,我看到:
that result metrics includes expected time service.doSomeJob()
Aspect
会阻止我的方法还是什么把戏?我试图找到一些性能遗漏?
在这个方法中只是包装了一个同步值:
Mono.just(service.doSomeJob());
因此 service.doSomeJob()
被同步调用(我希望它不会阻塞 I/O...)并且在其中花费的时间直接用于构建反应管道。
我正在尝试创建我的 @Around
注释来制作 Prometheus
指标。
看点:
@Around("@annotation(TimeMetric)")
public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
// duration.startTimer();
Object object = joinPoint.proceed();
// durationTimer.setDuration();
return object;
}
控制器:
@TimeMetric
@GetMapping(path = "")
Mono<SomeResult> health() {
return Mono.just(service.doSomeJob());
}
我的预期行为是:
I will get metrics without execution time
service.doSomeJob()
, as I returnMono
.
但是当我得到结果时,我看到:
that result metrics includes expected time
service.doSomeJob()
Aspect
会阻止我的方法还是什么把戏?我试图找到一些性能遗漏?
在这个方法中只是包装了一个同步值:
Mono.just(service.doSomeJob());
因此 service.doSomeJob()
被同步调用(我希望它不会阻塞 I/O...)并且在其中花费的时间直接用于构建反应管道。