한국어 | English
This project is a simple tool to measuring query counts in a JDBC API(Spring Data JPA(Hibernate), MyBatis, ...) environment.
You can seamlessly measure query counts also in a Multi-DataSource environment.
Hibernate:
select
id,
name
from
example
Hibernate:
select
count(id)
from
example
ERROR --- 'GET /examples' - totalQueryCount: 2, totalSpendTime: 7ms
Important
Spring Boot 3.x uses jakarta.*
packages while Spring Boot 2.x uses javax.*
packages. Make sure to select the compatible library version for your project.
Choose the appropriate version based on your Spring Boot version:
Spring Boot Version | Library Version |
---|---|
Spring Boot 2.x | 2.x.x-spring-boot-2 |
Spring Boot 3.x | 2.x.x-spring-boot-3 |
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
// For Spring Boot 2.x
implementation 'com.github.Hyeon9mak:multi-datasource-query-counter:2.3.2-spring-boot-2'
// For Spring Boot 3.x
// implementation 'com.github.Hyeon9mak:multi-datasource-query-counter:2.3.2-spring-boot-3'
}
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
dependencies {
// For Spring Boot 2.x
implementation("com.github.Hyeon9mak:multi-datasource-query-counter:2.3.2-spring-boot-2")
// For Spring Boot 3.x
// implementation("com.github.Hyeon9mak:multi-datasource-query-counter:2.3.2-spring-boot-3")
}
The priority order is as follows: error
> warn
> info
.
The default value for enable
is false
, and the default value for count
is 1
.
query-counter.logging.level:
error:
enable: true
count: 5
warn:
enable: true
count: 2
info:
enable: false
@CountQueries
annotation is used to specify the API you want to measure.
@CountQueries
@GetMapping("/examples")
public List<Example> getExamples() {
return repository.getExamples();
}
Start the application and check the log.
ERROR --- 'GET /examples' - totalQueryCount: 2, totalSpendTime: 7ms
Enjoy it! 🎉
- Click here to read the guide for Java Asynchronous environments.
- Click here to read the explain for Kotlin Coroutine environments.
It's based on the JDBC API and Spring AOP, CGLib proxy.
... That's it!