Monitoring reactor schedulers

Because reactive streams usually operate on different reactor schedulers, it may be beneficial to track fine-grained metrics regarding their operation. In some cases, it is plausible to use a custom ScheduledThreadPoolExecutor with a manual metric instrumentation. For example, let's assume we have the following class:

public class MeteredScheduledThreadPoolExecutor
       extends ScheduledThreadPoolExecutor {                         // (1)

   public MeteredScheduledThreadPoolExecutorShort(
      int corePoolSize,
      MeterRegistry registry                                         // (2)
   ) {
      registry.gauge("pool.core.size", this.getCorePoolSize());      // (3)
      registry.gauge("", this.getActiveCount());    //
      registry.gauge("pool.queue.size", this.getQueue().size ...

Get Hands-On Reactive Programming in Spring 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.