Since #12550 spring-boot makes use of HibernateMetrics provided by micrometer. Since version 1.4.0 HibernateQueryMetrics is also available in micrometer, but spring-boot doesn't configure it. I suppose adding a configuration for this binder would be a great addition. Now it's fragile to add this binder in user code, since HibernateMetricsAutoConfiguration makes some bean names transformations to get entity manager factory name. That's why I propose this change to be done on spring-boot side consistent with HibernateMetricsAutoConfiguration. However it's worth noting that HibernateQueryMetrics most certainly will create too much Meters because of a number of queries in regular application and in a way will degrade performance. So it's important to make this auto-configuration opt-in.

I will be happy to contribute if you think this feature is worth adding.

Comment From: wilkinsona

That sounds like a good addition. Thanks for the suggestion. Thanks too for the offer to contribute something. We're not yet quite sure how best to implement this so I think we'll need to hold off, certainly for now at least. We'll need to figure out how best to retain the existing registration of HibernateMetrics, while also allow users to opt-in to additional registration of HibernateQueryMetrics. It feels like it'll need to be programmatic rather than entirely property-based so that, for example, tags can be provided.

Comment From: izeye

For your information, HibernateMetrics and HibernateQueryMetrics have been deprecated in https://github.com/micrometer-metrics/micrometer/pull/2420.