Log Slow Queries Via DataSource-Proxy
Description: This application is a sample of logging only slow queries via DataSource-Proxy. A slow query is a query that has an execution time bigger than a specificed threshold in milliseconds.
Key points:
- for Maven, add in
pom.xml
the DataSource-Proxy dependency - create an bean post processor to intercept the
DataSource
bean - wrap the
DataSource
bean viaProxyFactory
and an implementation ofMethodInterceptor
- choose a threshold in milliseconds
- define a listener and override
afterQuery()