Add auto-configuration for Hibernate metrics

All Hibernate entityManagerFactories are automatically instrumented
and their statistics are included into Micrometer using its
HibernateMetrics binder.

Closes gh-12550
This commit is contained in:
Rui Figueira
2018-03-19 20:34:28 +00:00
committed by Stephane Nicoll
parent 3cb2246e7a
commit b6b92ba937
7 changed files with 314 additions and 0 deletions

View File

@@ -1774,6 +1774,25 @@ Auto-configuration will enable the instrumentation of all available RabbitMQ con
factories with a metric named `rabbitmq`.
[[production-ready-metrics-hibernate]]
==== Hibernate Metrics
Auto-configuration enables the instrumentation of all available Hibernate
`EntityManagerFactory` objects that have statistics enabled with a metric named
`hibernate`.
Metrics are also tagged by the name of the `EntityManagerFactory` that is derived from
the bean name.
To enable statistics on Hibernate `EntityManagerFactory` instances, JPA property `hibernate.generate_statistics` must be set to `true`. For example, on the default
`EntityManagerFactory`, you need to set the following property:
.application.properties
[source,properties,indent=0]
----
spring.jpa.properties.hibernate.generate_statistics=true
----
[[production-ready-metrics-custom]]
=== Registering custom metrics