[英]HikariCp metrics collection using micrometer in Java springboot application by configuring it in
community, I have a requirement where I want to do HikariCp metrics collection using micrometre in Java spring boot application by configuring it.社区,我有一个要求,我想通过配置在 Java Spring Boot 应用程序中使用微米来进行 HikariCp 指标收集。 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 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.注意:在 Hikari 的官方文档中,他们提供了一种为 dropwizard 设置度量注册表的方法,但我想用 Micrometre 来做。
only data source autoconfigured is exposed for metrics in my case I have a custom Hikari data source configuration.在我的情况下,只有自动配置的数据源会暴露给指标我有一个自定义的 Hikari 数据源配置。
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);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.