October 2018
Intermediate to advanced
556 pages
15h 18m
English
In Project Reactor 3.2, reactive types Flux and Mono obtained a metrics() operator. This reports operational metrics regarding the stream when called. The metrics() operator behaves similarly to the log() operator. It cooperates with the name() operator to build a target metric name and add a tag. For example, the following code demonstrates how to add metrics to an outgoing SSE stream:
@GetMapping( path = "/temperature-stream", produces = MediaType.TEXTEVENTSTREAMVALUE) public Flux<Temperature> events() { return temperatureSensor.temperatureStream() // (1) .name("temperature.stream") // (2) .metrics(); // (3) }
Here, the temperatureSensor.temperatureStream() returns Flux<Temperature> (1), while the name("temperature.stream") ...