reactor/reactor-pool

Provide Micrometer PoolMetricsRecorder adapter

philwebb opened this issue · 3 comments

As discussed in spring-projects/spring-boot#32072 it would be generally useful if an implementation of PoolMetricsRecorder were provided that delegates to Micrometer APIs.

Motivation

reactor-pool provides a PoolMetricsRecorder interface that can be used to record metrics. Users that want to surface metrics using https://micrometer.io/ will need to adapt the PoolMetricsRecorder to the appropriate micrometer APIs. This implementation could be provided by reactor-pool (using an optional Micrometer dependency) to save the same code being written multiple times.

Desired solution

An optional Micrometer dependency is added and a MicrometerPoolMetricsRecorder implementation is added.

Considered alternatives

The implementation could be provided in a third-party library.

Additional context

MicrometerMetricsTracker from Hikari might be good inspiration. It solves a similar problem where a library specific IMetricsTracker interface is adapted to Micrometer.

This should be doable, I have implemented such a recorder + a helper that turns InstrumentedPool.metrics() PoolMetrics into gauges + a DocumentedMeter enum (about 300 lines of code total).

the main difficulty is that we really want the users to explicitly provide a MeterRegistry. offering such an API in the reactor-pool module would mean that the Micrometer API bleeds into our public API, and I haven't been able to solve that with an optional dependency.

so now I have to modify the build and project structure from a single root project to a multi-project build, in anticipation of the creation of a reactor-pool-micrometer second module for this issue. this represents a bit of work as a pre-requisite to fixing this issue.

see PR #164

I'm after feedback on the choices around meter names, tags and types. see notably this enum and this test

this will take the form of a new module in 2022.0.0 BOM (about to go RC1). version will be 0.1.0, unlike main pool artifact which goes 1.0.0.