Comments (7)
@binakot wrote a wiki page for that.
https://github.com/ttddyy/datasource-proxy/wiki/Logging-slow-queries
from datasource-proxy.
Regular query logging listeners write out query after execution has finished. So, it has time populated.
For slow query loggers, it writes out query when it passed threshold time. For example, if a query takes 10min and threshold time is set to 1min, the slow query logger prints out query when it passed 1 min while query is still running.
Currently, slow query logger is not updating execution time(elapsed time). So, it'll always show 0 in time.
I'll update to populate the time with current elapsed time. So, for slow queries, it will show threshold time(or threshold time +alpha based on when scheduler execute the thread) in time field.
(1min for above example).
Meanwhile, you can update slow query class like this to achieve same behavior:
SLF4JSlowQueryListener slowQueryListener = new SLF4JSlowQueryListener(...) {
@Override
protected void onSlowQuery(ExecutionInfo execInfo, List<QueryInfo> queryInfoList, long startTimeInMills) {
execInfo.setElapsedTime(System.currentTimeMillis() - startTimeInMills);
super.onSlowQuery(execInfo, queryInfoList, startTimeInMills);
}
};
from datasource-proxy.
from datasource-proxy.
Ok, so you want to log queries after they have finished which includes actual query execution time, only when they exceed threshold time.
In that case, you can use regular query logging listeners extending them to write query only when it took longer than threshold.
long thresholdInMills = ...
SLF4JQueryLoggingListener listener = new SLF4JQueryLoggingListener(){
@Override
public void afterQuery(ExecutionInfo execInfo, List<QueryInfo> queryInfoList) {
if (execInfo.getElapsedTime() >= thresholdInMills) {
super.afterQuery(execInfo, queryInfoList);
}
}
};
listener.setLogLevel(SLF4JLogLevel.WARN);
from datasource-proxy.
Perfect thanks
from datasource-proxy.
I was confused with that too. Good that I checked closed issues.
An hour ago I was ready to submit a new bug. 😄
I think this information should to add in the documentation with this example.
from datasource-proxy.
@ttddyy Awesome! Thanks!
from datasource-proxy.
Related Issues (20)
- Properly call before/after method callback on `ProxyDataSource#getConnection`
- module-info.java HOT 2
- Add `ProxyDataSourceBuilder#buildProxy()`
- Add `ProxyJdbcObject#getProxyConfig`
- Connection is not returned to the pool if connection.getTransactionIsolation() throws an exception HOT 1
- No handling of equals method for two connection object HOT 5
- Possibility of intercepting method getConnection() if exception is thrown by original DataSource HOT 2
- equals method of ProxyLogicSupport class not working as expected. HOT 1
- Expose proxy object to method callback
- Reduce transaction Isolation level queries in ProxyDataSource with HikariCP and PostgreSQL HOT 2
- Use monotonic time to measure elapsed time in SystemStopWatch
- Record number of result set rows in `DataSourceQueryCountListener` HOT 2
- Make "AbstractQueryLogEntryCreator#chompIfEndWith" defensive for empty string
- Micrometer support HOT 2
- Got number of type instead null HOT 1
- Add SQL Format Option HOT 1
- Proxying generated keys not working with MS-SQL server data source HOT 4
- Document about Jakarta namespace support HOT 3
- Setting different names for each DataSource used by a routing DataSource HOT 3
- Support Quarkus
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datasource-proxy.