Skip to Content
Hands-On Reactive Programming in Spring 5
book

Hands-On Reactive Programming in Spring 5

by Oleh Dokuka, Igor Lozynskyi
October 2018
Intermediate to advanced
556 pages
15h 18m
English
Packt Publishing
Content preview from Hands-On Reactive Programming in Spring 5

Monitoring reactor flows

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") ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Spring Microservices in Action, Second Edition

Spring Microservices in Action, Second Edition

John Carnell, Illary Huaylupo Sanchez

Publisher Resources

ISBN: 9781787284951Supplemental Content