I am using spring-integration in order to connect to an external JDBC database and I want to track execution times per db connection.
Apart from using Spring AOP and wrapping my service method to measure statistics, is there any way to measure times directly in the spring-integration? Meaning to get exactly how much the database connection was used per request?
Thanks
The JDBC is used not only in Spring Integration, so it is not correct to request such a feature exactly from the Spring Integration perspective. Any other applications without any integration features should benefit from such a feature as well.
I think what you are looking for is covered by the DB metrics in Spring Boot: https://docs.spring.io/spring-boot/docs/2.1.5.RELEASE/reference/htmlsingle/#production-ready-metrics-jdbc
If you don't use Spring Boot, consider to apply the mentioned HikariCP: https://github.com/brettwooldridge/HikariCP/wiki/Dropwizard-Metrics
Otherwise you always can override execute(PreparedStatementCreator psc, PreparedStatementCallback<T> action) and wrap a super call into your own metric to measure a time for that execute() call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With