-
Notifications
You must be signed in to change notification settings - Fork 981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for per-query metrics in Hibernate statistics #1006
Comments
Sounds great. A PR would be welcome! |
Could you provide an example of how to use the per-query metric support in Hibernate statistics? I've tried to find out how to have this functionality work with Spring boot through the spring-actuator to expose hibernate statistics with per-query metrics. I've had little success until i found this great change! 🙌 |
Note that Hibernate metrics have moved to the Hibernate project, in the hibernate-micrometer module. You need to enable statistics for Hibernate by setting the @Bean
MeterBinder hibernateQueryMetrics(EntityManagerFactory entityManager) {
return new HibernateQueryMetrics(entityManager.unwrap(SessionFactoryImplementor.class), "mySess", Tags.empty());
} |
Current implementation of HibernateMetrics exposed counters & also time gauges for max execution queries, however no tags are provided in order to know about which query those metrics are related.
I believe this could be very useful and could be done using current Hibernate Statistics class implementation.
For example the TimeGauge hibernate.query.executions.max could be tag with a query tag and the value could be provided by
Statistics.getQueryExecutionMaxTimeQueryString()
.Also the other counter metrics could be retrieved by query using:
Statistics.getQueries()
Statistics.getQueryStatistics(String query)
What do u think ?
The text was updated successfully, but these errors were encountered: