Skip to content
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

Hibernate statistics and metrics are no longuer showing #21177

Closed
AchrafBelkahla opened this issue Nov 3, 2021 · 13 comments · Fixed by #21194
Closed

Hibernate statistics and metrics are no longuer showing #21177

AchrafBelkahla opened this issue Nov 3, 2021 · 13 comments · Fixed by #21194

Comments

@AchrafBelkahla
Copy link

AchrafBelkahla commented Nov 3, 2021

hello,

I just migrated to quarkus 2.4.1. The metrics and statistics are no longuer displayed in console while the sql log is OK !

My "application.properties" file :

...

quarkus.hibernate-orm.database.generation=none

quarkus.hibernate-orm.log.sql=true

quarkus.hibernate-orm.statistics=true

quarkus.hibernate-orm.metrics.enabled=true

...
@quarkus-bot
Copy link

quarkus-bot bot commented Nov 3, 2021

/cc @Sanne, @ebullient, @gsmet, @jmartisk, @yrodiere

@geoand
Copy link
Contributor

geoand commented Nov 4, 2021

Can you attach a sample project that was working before 2.4.1 and is no longer working with 2.4.1?

Thanks

@jmartisk
Copy link
Contributor

jmartisk commented Nov 4, 2021

This was intentionally introduced by #20693
I was suggesting maybe we might want to add a separate config property to enable statistics logging, but we haven't done that yet.

@geoand
Copy link
Contributor

geoand commented Nov 4, 2021

Thanks for the information @jmartisk.

@AchrafBelkahla
Copy link
Author

@jmartisk Thank you for replying.
So if i'm getting it right, the metrics logging is now deactivated by default and can't be logged due to the changes made in
#20693 : forcing the property to false ?

@geoand You still need the sample project ? to be more specific, I was working with 2.2.3 before switching to 2.4.1

@geoand
Copy link
Contributor

geoand commented Nov 4, 2021

@geoand You still need the sample project ? to be more specific, I was working with 2.2.3 before switching to 2.4.1

Not necessary after @jmartisk's comment

@jmartisk
Copy link
Contributor

jmartisk commented Nov 4, 2021

Logging of statistics is deactivated right now and can't be turned on. Metrics (meaning exposing the statistics via Micrometer or SmallRye Metrics) will still work, the statistics just won't appear in the server log.
If that's a problem, we can add a config property to enable that logging (but it will be off by default).

@Sanne , it looks like your condition in #20666 (comment) was just fulfilled :)

I can prepare a PR to add the property.

@AchrafBelkahla
Copy link
Author

@jmartisk yes please :) We rely too much on those logs.

@Sanne
Copy link
Member

Sanne commented Nov 4, 2021

I'm still not persuaded by it but OK let's fix it since it was an existing "feature"

@AchrafBelkahla I hope you know you can also invoke getStatistics() on any org.hibernate.Session and read the statistics you're interested in, and format then or print them in any format you like?

I would generally suggest to use this approach instead.

@AchrafBelkahla
Copy link
Author

@Sanne Well, I didn't :/
Thank you for the info and for the rapid intervention :)

@gavinking
Copy link

FTR I agree with Sanne. I don't think statistics really belong in the log. At least, except for something the user is really especially interested in, enough to log it themself.

@quarkus-bot quarkus-bot bot added this to the 2.5 - main milestone Nov 4, 2021
@klezovics
Copy link

@Sanne

I hope you know you can also invoke getStatistics() on any org.hibernate.Session

Hi ! Thank you for this comment !
I have a follow up question ... I am using PanacheRepository with Quarkus.
And I am doing a load test for which I need to collect statistic.

I can @Inject an entityManager and my xxxRepository class. How do I get the session, which is used by my xxxRepository class to get the statistics out of it.

@Sanne
Copy link
Member

Sanne commented Nov 18, 2021

The Panache repository is using the same EntityManager that you'd get by injecting it, as it will look it up via CDI from the same context.

You can also use Panache.getEntityManager() if there is a single persistence unit, or you can use Panache.getEntityManager(Clazz) to get the one managing that specific type if you need to manage ambiguity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants