Jooq: HikariCP connection monitoring

265 Views Asked by At

With Jooq how can I monitor the HikariCp Connection pool?

Just like for JPA I can use flexy-pool.

But for flexy-pool, we need to provide configuration by extending HickariCpJpaPostgresConfiguration.

But for Jooq unable to find anything.

Metrics I am looking for:

  • ConcurrentConnectionRequestCount
  • ConcurrectConnection
  • ConnectionAcquireMillis
  • ConnectionLeaseMillis
1

There are 1 best solutions below

0
On

Jooq configuration accepts passing connection pool (DataSource object) to it:

    @Autowired
    private FlexyPoolDataSource flexyPoolDataSource;

    @Bean
    public DefaultDSLContext dsl() {
        return new DefaultDSLContext(configuration());
    }

    public DefaultConfiguration configuration() {
        org.jooq.impl.DefaultConfiguration jooqConfiguration = 
            new org.jooq.impl.DefaultConfiguration();
        jooqConfiguration.set(
            new org.jooq.impl.DataSourceConnectionProvider(flexyPoolDataSource));
        return jooqConfiguration;
    }

So you can proxy your original datasource with any wrapper you want, flexy-pool datasource, you mentioned, also implements DataSource

public class FlexyPoolDataSource<T extends DataSource> implements DataSource, ...