use of fish.payara.jdbc.stats.SlowSqlTrace in project Payara by payara.
the class JdbcStatsProvider method traceSQLEvent.
/**
* Whenever a sql statement that is traced is to be cache for monitoring
* purpose, the SQLTrace object is created for the specified sql and
* updated in the SQLTraceCache. This is used to update the
* frequently used and slowest sql queries.
*
* @param poolName
* @param appName
* @param sql
* @param moduleName
* @param executionTime
*/
@ProbeListener(JdbcRAConstants.SQL_TRACING_DOTTED_NAME + JdbcRAConstants.TRACE_SQL)
public void traceSQLEvent(@ProbeParam("poolName") String poolName, @ProbeParam("appName") String appName, @ProbeParam("moduleName") String moduleName, @ProbeParam("sql") String sql, @ProbeParam("executionTime") long executionTime) {
PoolInfo poolInfo = new PoolInfo(poolName, appName, moduleName);
if (this.poolInfo.equals(poolInfo)) {
if (freqSqlTraceCache != null) {
if (sql != null) {
SQLTrace cacheObj = new SQLTrace(sql, 1, System.currentTimeMillis());
freqSqlTraceCache.checkAndUpdateCache(cacheObj);
}
}
// the cache
if (slowSqlTraceCache != null && sql != null) {
SQLTrace cacheObj = new SlowSqlTrace(sql, 1, System.currentTimeMillis(), executionTime);
slowSqlTraceCache.checkAndUpdateCache(cacheObj);
}
}
}
use of fish.payara.jdbc.stats.SlowSqlTrace in project Payara by payara.
the class JdbcStatsProvider method getSlowSqlQueries.
@ManagedAttribute(id = "slowSqlQueries")
public ListStatistic getSlowSqlQueries() {
// Make sure no data from previous execution is kept
slowSqlQueries.reset();
slowSqlQueries.clear();
// Get slow queries and process them
List<SlowSqlTrace> slowTraces = slowSqlTraceCache.getSlowestSqlQueries();
for (SlowSqlTrace trace : slowTraces) {
CountStatisticImpl stat = new CountStatisticImpl(trace.getQueryName(), StatisticImpl.UNIT_MILLISECOND, "Longest execution time");
stat.setCount(trace.getSlowestExecutionTime());
slowSqlQueries.add(stat);
}
return slowSqlQueries;
}
Aggregations