spring boot 2.6.4, spring data r2dbc and pgsql, prometheus metrics activated, There is no metric for connection pool. if i debug ConnectionPoolMetricsAutoConfiguration, i see that if (connectionFactory instanceof ConnectionPool) return always false.

So no ConnectionPoolMetrics created

SpringBoot No metrics are bound for R2DBC ConnectionPools that have been wrapped

Comment From: wilkinsona

Something's proxied the ConnectionPool so that we can no longer tell that's what it is. We may be able to unwrap it (io.r2dbc.spi.Wrapped.unwrap()) but it's impossible to tell without knowing more. Can you please share a complete, yet minimal example that reproduces the problem? You can do so by zipping it up and attaching it to this issue or pushing it to a separate repository on GitHub.

Comment From: hongjunan

thank you, i solved this problem

bean {
    ConnectionPoolMetrics((ref() as Wrapped<ConnectionPool>).unwrap(), "r2dbc", emptyList())
        .bindTo(ref())
}

Comment From: wilkinsona

That looks like a good workaround. We should be able to do that automatically for you in our metrics auto-configuration.

Comment From: guerricmerleHUG

Thanks you for your reactivity.