community, I have a requirement where I want to do HikariCp metrics collection using micrometre in Java spring boot application by configuring it. I was looking around but I could not find much help in the official documentation
https://github.com/brettwooldridge/HikariCP/tree/dev/src/main/java/com/zaxxer/hikari
Can anyone please help me with how to do that? Note: In the official documentation of Hikari they have provided a way to set metric registry for dropwizard but I wanted to do it with Micrometre.
only data source autoconfigured is exposed for metrics in my case I have a custom Hikari data source configuration.
public myDataSource(){
DataSource datasource = this.createDataSource();// you can write your own implementation to create datasource. you can pass URL, username etc to create it.
this.setUpHikariWithMetrics();
}
public void setUpHikariWithMetrics() {
if (dataSource instanceof HikariDataSource) {
((HikariDataSource) dataSource).setMetricRegistry(metricRegistry);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.