spring-projects / spring-projects/spring-boot

Add auto-configuration for Hibernate query metrics

Open
#23,131 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: pending-design-work theme: observability type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

Since #12550 spring-boot makes use of HibernateMetrics provided by micrometer. Since version 1.4.0 HibernateQueryMetrics is also available in micrometer, but spring-boot doesn't configure it. I suppose adding a configuration for this binder would be a great addition.
Now it's fragile to add this binder in user code, since HibernateMetricsAutoConfiguration makes some bean names transformations to get entity manager factory name. That's why I propose this change to be done on spring-boot side consistent with HibernateMetricsAutoConfiguration.
However it's worth noting that HibernateQueryMetrics most certainly will create too much Meters because of a number of queries in regular application and in a way will degrade performance. So it's important to make this auto-configuration opt-in.

I will be happy to contribute if you think this feature is worth adding.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing HibernateMetricsAutoConfiguration and Micrometer's HibernateQueryMetrics integration, paying attention to the entity manager factory bean-name transformations. Add matching opt-in auto-configuration and verify that query metrics are enabled only when explicitly requested, without disrupting the existing HibernateMetrics setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
observability
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.