|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2018 the original author or authors.
|
|
|
|
* Copyright 2012-2019 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -20,6 +20,7 @@ import java.util.Collections;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.persistence.EntityManagerFactory;
|
|
|
|
import javax.persistence.EntityManagerFactory;
|
|
|
|
|
|
|
|
import javax.persistence.PersistenceException;
|
|
|
|
|
|
|
|
|
|
|
|
import io.micrometer.core.instrument.MeterRegistry;
|
|
|
|
import io.micrometer.core.instrument.MeterRegistry;
|
|
|
|
import io.micrometer.core.instrument.binder.jpa.HibernateMetrics;
|
|
|
|
import io.micrometer.core.instrument.binder.jpa.HibernateMetrics;
|
|
|
@ -65,8 +66,14 @@ public class HibernateMetricsAutoConfiguration {
|
|
|
|
private void bindEntityManagerFactoryToRegistry(String beanName,
|
|
|
|
private void bindEntityManagerFactoryToRegistry(String beanName,
|
|
|
|
EntityManagerFactory entityManagerFactory, MeterRegistry registry) {
|
|
|
|
EntityManagerFactory entityManagerFactory, MeterRegistry registry) {
|
|
|
|
String entityManagerFactoryName = getEntityManagerFactoryName(beanName);
|
|
|
|
String entityManagerFactoryName = getEntityManagerFactoryName(beanName);
|
|
|
|
new HibernateMetrics(entityManagerFactory, entityManagerFactoryName,
|
|
|
|
try {
|
|
|
|
Collections.emptyList()).bindTo(registry);
|
|
|
|
new HibernateMetrics(entityManagerFactory.unwrap(SessionFactory.class),
|
|
|
|
|
|
|
|
entityManagerFactoryName, Collections.emptyList())
|
|
|
|
|
|
|
|
.bindTo(registry);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (PersistenceException ex) {
|
|
|
|
|
|
|
|
// Continue
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|