Just want to know if there is any way to get the response time of web client of spring web-flux?
you also have the possibility to use elapsed()
for this kind of thing
webClient.get().uri("/bla").retrieve()
.bodyToMono(String.class)
.elapsed() // map the stream's time into our streams data
.doOnNext(tuple -> log.info("Milliseconds for retrieving {}", tuple.getT1()))
.map(Tuple2::getT2) // after outputting the measurement, return the data only
Note, that elapsed()
elapses the whole reactive stream, so if you're doing something before the webClient... part, you should put an elapsed() before that - this resets the timer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With