Polish "Add auto-configuration for Hibernate metrics"

Closes gh-12550
This commit is contained in:
Stephane Nicoll
2018-04-17 13:41:42 +02:00
parent b6b92ba937
commit a85998f4c3
5 changed files with 64 additions and 34 deletions

View File

@@ -1768,32 +1768,34 @@ Also, Hikari-specific metrics are exposed with a `hikaricp` prefix. Each metric
by the name of the Pool (can be controlled with `spring.datasource.name`).
[[production-ready-metrics-rabbitmq]]
==== RabbitMQ Metrics
Auto-configuration will enable the instrumentation of all available RabbitMQ connection
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
`EntityManagerFactory` instances that have statistics enabled with a metric named
`hibernate`.
Metrics are also tagged by the name of the `EntityManagerFactory` that is derived from
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:
To enable statistics, the standardJPA property `hibernate.generate_statistics` must be
set to `true`. You can enable that on the auto-configured `EntityManagerFactory` as shown
in the following example:
.application.properties
[source,properties,indent=0]
----
spring.jpa.properties.hibernate.generate_statistics=true
spring.jpa.properties.hibernate.generate_statistics=true
----
[[production-ready-metrics-rabbitmq]]
==== RabbitMQ Metrics
Auto-configuration will enable the instrumentation of all available RabbitMQ connection
factories with a metric named `rabbitmq`.
[[production-ready-metrics-custom]]
=== Registering custom metrics
To register custom metrics, inject `MeterRegistry` into your component, as shown in the