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
Provide metric auto-configuration for spring data repository [DATACMNS-1420] #1853
Comments
Andy Wilkinson commented This was originally raised as a Spring Boot issue |
Mark Paluch commented Thanks for raising this issue. When looking at the data side, you can various perspectives and levels of detail. Repositories are a common API to use. If we look what's inside a repository we will recognize there may be multiple things going on in terms of statements and execution models. Repositories use typically a Template API that is store specific and Template API calls translate to one or more data store interactions. There's fair amount of metric integrations that you can plug in (e.g. on driver level), so the actual questions to answer are:
From an integration perspective, it would make the most sense to add another interceptor to RepositoryFactorySupport that adds the observability aspect to all (metrics-enabled) repositories. This approach would only consider repositories but not the underlying data-store-specific Template API |
Julien Fougere commented Hi Mark Paluch. Thanks for your comment. My primarily thoughts were to add execution time metrics at a repository level (so including provided generic methods as well as user defined methods). For example with the following repository: @Repository
public interface BrandRepository extends JpaRepository<Brand, Integer> {
@QueryHints(value = {@QueryHint(name = HINT_COMMENT, value = "86314aab-1287-4118-b5da-296fec744842")}, forCounting = false)
Optional<Brand> findByName(String name);
} We would get execution time for method such as CrudRepository.save as well as BrandRepository.findByName.
|
Oliver Drotbohm commented I am not entirely sold that Spring Data is the right place to implement those things. Everything actuator and metrics lives in Boot these days and we would not be able to make use of the integration APIs living there. We currently don't expose anything Spring Data related for any module, except MongoDB driver JMX stats |
Andy Wilkinson commented
That's just three examples off the top of my head. In each case, supporting Micrometer directly (rather than relying on Boot to do it) makes sense to me as it means that all users of the project can benefit from Micrometer support irrespective of whether Spring Boot is being used. Where I think Boot should come into it is with auto-configuring the Micrometer support that the project provides.
What APIs are you referring to? I'm struggling to think of any that would make it easier for Spring Data to provide repository-level Micrometer Metrics |
Julien Fougere commented Any updates on this improvement ? sprint data or spring boot scope ? |
Spring Boot 2.5 picks up Spring Data Repository Metrics: https://docs.spring.io/spring-boot/docs/2.5.x-SNAPSHOT/reference/html/production-ready-features.html#production-ready-metrics-data-repository |
Auto-configurations are generally managed by Spring Boot. As noted by @timtebeek, Spring Boot has integrated with Spring Data's repository metrics so closing this ticket here. |
yes @timtebeek agreed. Thanks for the news. I see that the metrics are tagged with
Let's say I have a |
Julien Fougere opened DATACMNS-1420 and commented
With spring boot actuator we get automatically metrics around a whole bunch of things (jvm, cpu, tomcat, file, log, mvc, jersey, webflux, http client, rabbitmq, hibernate, cache, datasource, etc...) but we don't get any metrics related to spring data repositories.
My proposition is to add support for that and also auto-configuration from spring-boot.
What do u think ?
Locally I have a working project for jpa repositories that is adding a time gauge with class & method name as tags. However I haven't been able to see how to auto-configure it in a spring-boot way so I created a EnableJpaMetricsRepositories annotation that plug a interceptor (advice) around repositories via the repositoryFactoryBean.
1 votes, 5 watchers
The text was updated successfully, but these errors were encountered: