Class HibernateStatisticsCollector

java.lang.Object
io.prometheus.client.Collector
io.prometheus.client.hibernate.HibernateStatisticsCollector

public class HibernateStatisticsCollector extends Collector
Collect metrics from one or more Hibernate SessionFactory instances.

Usage example for a single session factory:

 new HibernateStatisticsCollector(sessionFactory, "myapp").register();
 
Usage example for multiple session factories:
 new HibernateStatisticsCollector()
     .add(sessionFactory1, "myapp1")
     .add(sessionFactory2, "myapp2")
     .register();
 
If you are in a JPA environment, you can obtain the SessionFactory like this:
 SessionFactory sessionFactory =
     entityManagerFactory.unwrap(SessionFactory.class);
 

When enablePerQueryMetrics() has been called, certain metrics like execution time are collected per query. This may create a lot of monitoring data, so it should be used with caution.