Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Hibernate statistics are not exposed even if corresponding configuration are applied #4791

Closed
klopfdreh opened this issue Dec 16, 2021 · 7 comments
Assignees
Labels
status/in-progress Something is happening
Milestone

Comments

@klopfdreh
Copy link
Contributor

klopfdreh commented Dec 16, 2021

Description:
As mentioned in the title, the hibernate statistics are not exposed even if I set the property spring.jpa.properties.hibernate.generate_statistics=true in the application.yaml / application.properties

Release versions:
2.9.1

Steps to reproduce:

  1. Just start the server and set the following properties in the application.yml / application.properties.
    yaml-example:
    management:
      endpoints:
        prometheus:
          enabled: true
        web:
          exposure:
            include: "*"
        jmx:
          exposure:
            include: "*"
      metrics:
        tags:
          application: scdf_server
        export:
          prometheus:
            enabled: true
            rsocket:
              enabled: true
              host: localhost
              port: 7001
    spring:
        jpa:
          properties:
            hibernate:
              dialect: <yourdialect>
              generate_statistics: true
  1. Access http://localhost:9393/management/prometheus and search for example for hibernate_query_executions_max_seconds.
  2. According to hibernate this should show the query executions max seconds, but this and other properties are not exposed.

Note: I double checked if "spring" is applied on the same level as server and management.
Note2: This was working till version 2.9.0

@github-actions github-actions bot added the status/need-triage Team needs to triage and take a first look label Dec 16, 2021
@markpollack markpollack added the status/need-investigation Oh need to look under a hood label May 17, 2022
@markpollack markpollack added this to the 2.10.0-RC1 milestone May 17, 2022
@markpollack markpollack removed the status/need-triage Team needs to triage and take a first look label May 17, 2022
@markpollack markpollack modified the milestones: 2.10.0-RC1, 2.10.1 Oct 13, 2022
@markpollack markpollack modified the milestones: 2.10.1, Priority Backlog Jan 5, 2023
@klopfdreh
Copy link
Contributor Author

Because the statistics generation of hibernate has been moved to the hibernate project org.hibernate:hibernate-micrometer I guess this dependency has to be added to the classpath. See: https://docs.spring.io/spring-boot/docs/2.7.8/reference/htmlsingle/#actuator.metrics.supported.hibernate

I am going to try this out and report back if this is working.

@klopfdreh
Copy link
Contributor Author

klopfdreh commented Mar 8, 2023

Good news - that was the issue here - see the result:

image

Just add the following dependency to the pom.xml (https://github.com/spring-cloud/spring-cloud-dataflow/blob/main/spring-cloud-dataflow-server/pom.xml)

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-micrometer</artifactId>
</dependency>

application.yml:

spring:
  jpa:
    properties:
      hibernate:
        generate_statistics: true

@onobc
Copy link
Contributor

onobc commented Mar 8, 2023

Awesome find @klopfdreh ! Thanks for this. We will also make sure we have test coverage in this area of the metrics so that we find it before it goes out.

@onobc onobc added the status/need-triage Team needs to triage and take a first look label Mar 8, 2023
@onobc onobc modified the milestones: Priority Backlog, 2.10.3 Mar 8, 2023
@onobc onobc added status/in-progress Something is happening and removed status/need-investigation Oh need to look under a hood status/need-triage Team needs to triage and take a first look labels Apr 28, 2023
@onobc
Copy link
Contributor

onobc commented Apr 28, 2023

@klopfdreh previously were the stats automatically exposed or did you have to set the spring.jpa.properties.hibernate.generate_statistics=true to get them to show up?

@klopfdreh
Copy link
Contributor Author

@onobc it’s a long time ago when I configured our environment, but I set the property directly from beginning because I thought this needs to be configured. I didn’t test it without set this property. But what I noticed is that even if I set the property it stopped working to expose the statistics which was the reason for me to investigate this issue.

I would suggest to not expose the statistics by default, because it has some impacts to the server runtime.

@onobc
Copy link
Contributor

onobc commented Apr 29, 2023

I would suggest to not expose the statistics by default, because it has some impacts to the server runtime.

Agreed. I will add the dependency but users can opt-in by setting the property.

onobc added a commit to onobc/spring-cloud-dataflow that referenced this issue Apr 29, 2023
onobc referenced this issue in onobc/spring-cloud-skipper Apr 30, 2023
onobc referenced this issue in spring-attic/spring-cloud-skipper Apr 30, 2023
@onobc
Copy link
Contributor

onobc commented May 3, 2023

Closed via fab9354

@onobc onobc closed this as completed May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status/in-progress Something is happening
Development

No branches or pull requests

3 participants