我有一个与生产环境中使用Spring WebFlux和Project Reactor进行日志记录相关的问题。 我在暂存环境中有以下代码,它记录了与信号相关的大量信息,这对于调试非常有用。
Mono.zip(localChargeIdMono, userIdMono, merchantMono, totalAmountMono, requestIdMono)
.map(this::toNewTransaction)
.log("TransactionRepository.save")
.then(chargeMono)
.map(chargeResult -> Tuples.of(transaction, chargeResult))
.map(this::toNewTransactionUpdatedWithChargeResult))
.flatMap(tuple -> Mono.zip(
transactionRepository.save(tuple.getT1()),
paymentUpdateRepository.save(tuple.getT2())))
.log("t.p.save")
.map(Tuple2::getT1)
.map(this::toChargeTransactionDto);
但是我想知道这是否是在生产环境中记录日志的正确方式,或者我应该使用doOn*方法仅记录相关数据,例如副作用函数的输入/输出参数。
Mono.zip(localChargeIdMono, userIdMono, merchantMono, totalAmountMono, requestIdMono)
.map(this::toNewTransaction)
.donOnNext(e -> log.info(e))
.then(chargeMono)
.map(chargeResult -> Tuples.of(transaction, chargeResult))
.map(this::toNewTransactionUpdatedWithChargeResult))
.flatMap(tuple -> Mono.zip(
transactionRepository.save(tuple.getT1()),
paymentUpdateRepository.save(tuple.getT2())))
.donOnNext(e -> log.info(e))
.map(Tuple2::getT1)
.map(this::toChargeTransactionDto);
我希望你能提供一些与在生产环境中使用项目反应器相关的经验,因为这是我第一次使用。
谢谢