client_java icon indicating copy to clipboard operation
client_java copied to clipboard

Enabling per-query metrics in simpleclient_hibernate fails with Hibernate 4.2.0.Final

Open reftel opened this issue 5 years ago • 6 comments

If per-query metrics is enabled and Hibernate 4.2.0.Final is used (which, according to simpleclient_hibernate/pom.xml, is supported), HibernateStatisticsCollector fails due with an exception: java.lang.NoSuchMethodError: org.hibernate.stat.QueryStatistics.getExecutionTotalTime(), since that method was not added until version 5.2.0.

reftel avatar Aug 24 '18 10:08 reftel

That's expected. What change are you suggesting we make?

brian-brazil avatar Aug 24 '18 10:08 brian-brazil

Well, I see three options: either

  1. simply state that versions below 5.2.0 are not supported, or
  2. split the module into two (simpleclient_hibernate, which supports only 5.2.0 and above, and simpleclient_hibernate4, which does not provide the metric), or
  3. add the metric conditionally.

I can do a PR for either of them if needed.

reftel avatar Aug 24 '18 10:08 reftel

This is already a setting that you explicitly have to enable in your code, and the pom already states the dependency.

brian-brazil avatar Aug 24 '18 11:08 brian-brazil

I guess I wasn't clear in option 3. I meant checking using introspection whether the hibernate_per_query_execution_seconds_total metric should be added (and then fetching it in a roundabout way, e.g. introspection or dynamically loaded or generated code).

As for the pom, the comment by the hibernate dependency states "We support Hibernate versions >= 4.2". If the intention is to not support per-query metrics in versions before 5.2.0, then the comment should probably make that clear. "We support Hibernate versions >= 4.2, with per-query metrics in versions >= 5.2", or something like that?

reftel avatar Aug 24 '18 11:08 reftel

Ah, that comment was missed in code review. It should say 5.2.0 now.

brian-brazil avatar Aug 24 '18 11:08 brian-brazil

The comment still says "We support Hibernate versions >= 4.2": https://github.com/prometheus/client_java/blob/main/simpleclient_hibernate/pom.xml#L43

reftel avatar Aug 18 '23 05:08 reftel