Search in sources :

Example 1 with SlowSqlTrace

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);
        }
    }
}
Also used : SlowSqlTrace(fish.payara.jdbc.stats.SlowSqlTrace) SQLTrace(com.sun.gjc.util.SQLTrace) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) ProbeListener(org.glassfish.external.probe.provider.annotations.ProbeListener)

Example 2 with SlowSqlTrace

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;
}
Also used : SlowSqlTrace(fish.payara.jdbc.stats.SlowSqlTrace) CountStatisticImpl(org.glassfish.external.statistics.impl.CountStatisticImpl) ManagedAttribute(org.glassfish.gmbal.ManagedAttribute)

Aggregations

SlowSqlTrace (fish.payara.jdbc.stats.SlowSqlTrace)2 SQLTrace (com.sun.gjc.util.SQLTrace)1 ProbeListener (org.glassfish.external.probe.provider.annotations.ProbeListener)1 CountStatisticImpl (org.glassfish.external.statistics.impl.CountStatisticImpl)1 ManagedAttribute (org.glassfish.gmbal.ManagedAttribute)1 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)1