Publish Hibernate statement counts to Prometheus

FeatureSecurityService
Shipped
August 21, 2026 at 2:07 AM UTC
Author
Kamo
Commit
1d364c0

/actuator/prometheus already carried jdbc_* and hikaricp_* but no hibernate_*, because Spring Boot 3 only auto-configures those metrics when **************** is on the classpath. Added, plus hibernate.generate_statistics. The reason is concrete. Auditing this service for N+1 queries had to be done by grepping for association navigations, and that method is wrong in both directions: it over-counts, because an association name like 'vendor' or 'user' is lazy on some entities and eager on others (9 of 67 reported sites turned out to be eager and needed nothing), and it under-counts badly, because it sees .getX().getY() but not iteration over a lazy collection — which is most of the real surface. hibernate_statements_total answers the same question by measurement. An endpoint issuing 200 statements per call is visible whatever shape the code takes, and open-in-view being on means every one of those lazy loads is otherwise silent. Costs a few percent. Worth it in a service where the last audit found four separate O(rows) endpoints.

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing