Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to customize (tag) HikariCP Micrometer pool metrics #2264

Open
diogo-hs opened this issue Nov 19, 2024 · 0 comments
Open

[Question] How to customize (tag) HikariCP Micrometer pool metrics #2264

diogo-hs opened this issue Nov 19, 2024 · 0 comments

Comments

@diogo-hs
Copy link

diogo-hs commented Nov 19, 2024

We're undergoing some changes in our multi-module Spring app, and I need to collect a few Micrometer HikariCP metrics (more specifically, the hikaricp_connections_active) in a customized way.

Currently, it tags the metrics per data source pool:

# TYPE hikaricp_connections_active gauge
hikaricp_connections_active{pool="reading-pool",} 0.0
hikaricp_connections_active{pool="writing-pool",} 0.0

We have several modules in the app, and I'd like to tag the connections per module as well, something like:

# TYPE hikaricp_connections_active gauge
hikaricp_connections_active{pool="reading-pool",module="a",} 0.0
hikaricp_connections_active{pool="writing-pool",module="a",} 0.0
hikaricp_connections_active{pool="reading-pool",module="b",} 0.0
hikaricp_connections_active{pool="writing-pool",module="b",} 0.0

Initially, I thought about creating my own IMetricsTracker along with an interceptor (to identify which module code is requesting a connection) to set the metric I need, but the problem is it's a Gauge, and it relies on PoolStats and all the machinery behind the HikariPool (especially the ConcurrentBag) to feed the pool stats.

I couldn't find any way to customize the Hikari pool metrics management classes (most of them are package-protected, I believe purposefully).

Has anyone ever had to do something like this? Any suggestion on what direction I could take here? I really appreciate your time and feedback! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant