When hibernate is on the classpath and an EntityManagerFactory
is configured then
register a HibernateMetrics
bean so that the statistics from hibernate get published
to the metrics endpoint.
The exposed statistics are the same as those that would be exposed using Statistics.logSummary
from hibernate itself.
Issue: #2157
Comment From: mdeinum
Any thoughts on adding this to Spring Boot (or the quality of the request :) )
Comment From: snicoll
I've been thinking of that one lately. Have you tried with Hibernate 5? This also exposes only the stats if one primary EntityManager
is present. Might be a problem for those who are running with multiple persistence units.
Comment From: mdeinum
This has been tested with Hibernate 4.3.10 not Hibernate 5 .
I'll take a look at on how to refactor it for multiple persistence units, shouldn't be that difficult (I'll take a peek at the DataSourcePublicMetrics
which does the same if I recall correctly).
I have been thinking of making it also a bit more generic so that support for EclipseLink (for instance) could be added. Just like the metrics support for DataSource
s which adapts per type.
Comment From: mdeinum
Any thoughts on the updated code?
Comment From: snicoll
I am afraid I am personally out of cycles to look at this at the moment. The fact I have no indication it works with Hibernate 5 is also a reason.
Comment From: mdeinum
I can run the tests against both Hibernate 4.3 and Hibernate 5. Is there an easy way to do that with the current build? Override the version for hibernate?
Comment From: snicoll
A validation that it does work with Hibernate 5 is already good on its own. I haven't figured out yet how we'll integrate integration testing for Hibernate 5. Probably a dedicated sample (see #2763)
Comment From: snicoll
@mdeinum can you rebase your PR and make sure it works still? Thanks!
Comment From: mdeinum
@snicoll Rebased and fixed some of the new check style rules (tabs instead of spaces, copyright header etc.). Tests still green after this.
Comment From: mdeinum
@snicoll I did some polishing as there where still some check style errors.
Comment From: Bert-R
Is there any chance this will board Spring Boot?
Comment From: snicoll
@Bert-R there is a milestone version attached to it and I intend to honour it. So, yes. Maybe not in its current form though. There are a lot of stats there.
Comment From: Bert-R
@snicoll Great, thanks a lot!
Comment From: mdeinum
@snicoll anything I can do to polish this up? Good start would probably be to make it work with boot 2.0.0 (maybe we can have a chat about it during SpringIO (?) )
Comment From: snicoll
Of course!
Comment From: mdeinum
Ok. My rebase skills are seriously lacking today... I guess we can consider this pull request dead... I'll create a new one.
Comment From: philwebb
@mdeinum You can force push, no need to close it
Comment From: mdeinum
That is what I figured, after the fact. Squashed the commits and did a force push. That cleaned up things...
Comment From: snicoll
With the move to micrometer, I am afraid this PR can't be merged. I'd advise to discuss with the micrometer team to see if how this can be added.