Class HibernateQueryMetrics

  • All Implemented Interfaces:
    io.micrometer.core.instrument.binder.MeterBinder

    @NonNullApi
    @NonNullFields
    public class HibernateQueryMetrics
    extends Object
    implements io.micrometer.core.instrument.binder.MeterBinder
    A MeterBinder implementation that provides Hibernate query metrics. It exposes the same statistics as would be exposed when calling Statistics.getQueryStatistics(String). Note that only SELECT queries are recorded in QueryStatistics.

    Be aware of the potential for high cardinality of unique Hibernate queries executed by your application when considering using this MeterBinder.

    • Constructor Detail

      • HibernateQueryMetrics

        public HibernateQueryMetrics​(SessionFactory sessionFactory,
                                     String sessionFactoryName,
                                     Iterable<io.micrometer.core.instrument.Tag> tags)
        Create a HibernateQueryMetrics.
        Parameters:
        sessionFactory - session factory to use
        sessionFactoryName - session factory name as a tag value
        tags - additional tags
    • Method Detail

      • monitor

        public static void monitor​(io.micrometer.core.instrument.MeterRegistry registry,
                                   SessionFactory sessionFactory,
                                   String sessionFactoryName,
                                   String... tags)
        Create HibernateQueryMetrics and bind to the specified meter registry.
        Parameters:
        registry - meter registry to use
        sessionFactory - session factory to use
        sessionFactoryName - session factory name as a tag value
        tags - additional tags
      • monitor

        public static void monitor​(io.micrometer.core.instrument.MeterRegistry registry,
                                   SessionFactory sessionFactory,
                                   String sessionFactoryName,
                                   Iterable<io.micrometer.core.instrument.Tag> tags)
        Create HibernateQueryMetrics and bind to the specified meter registry.
        Parameters:
        registry - meter registry to use
        sessionFactory - session factory to use
        sessionFactoryName - session factory name as a tag value
        tags - additional tags
      • bindTo

        public void bindTo​(io.micrometer.core.instrument.MeterRegistry meterRegistry)
        Specified by:
        bindTo in interface io.micrometer.core.instrument.binder.MeterBinder