use of com.alibaba.druid.stat.JdbcDataSourceStat in project druid by alibaba.
the class StatFilter method resultSetOpenAfter.
@Override
protected void resultSetOpenAfter(ResultSetProxy resultSet) {
JdbcDataSourceStat dataSourceStat = resultSet.getStatementProxy().getConnectionProxy().getDirectDataSource().getDataSourceStat();
dataSourceStat.getResultSetStat().beforeOpen();
resultSet.setConstructNano();
StatFilterContext.getInstance().resultSet_open();
}
use of com.alibaba.druid.stat.JdbcDataSourceStat in project druid by alibaba.
the class StatFilter method statement_close.
@Override
public void statement_close(FilterChain chain, StatementProxy statement) throws SQLException {
chain.statement_close(statement);
JdbcDataSourceStat dataSourceStat = chain.getDataSource().getDataSourceStat();
dataSourceStat.getStatementStat().incrementStatementCloseCounter();
JdbcStatContext context = JdbcStatManager.getInstance().getStatContext();
if (context != null) {
context.setName(null);
context.setFile(null);
context.setSql(null);
}
}
use of com.alibaba.druid.stat.JdbcDataSourceStat in project druid by alibaba.
the class StatFilter method dataSource_releaseConnection.
@Override
public void dataSource_releaseConnection(FilterChain chain, DruidPooledConnection conn) throws SQLException {
chain.dataSource_recycle(conn);
long nanos = System.nanoTime() - conn.getConnectedTimeNano();
long millis = nanos / (1000L * 1000L);
JdbcDataSourceStat dataSourceStat = chain.getDataSource().getDataSourceStat();
dataSourceStat.getConnectionHoldHistogram().record(millis);
StatFilterContext.getInstance().pool_connection_close(nanos);
}
use of com.alibaba.druid.stat.JdbcDataSourceStat in project druid by alibaba.
the class StatFilter method statementCreateAfter.
@Override
public void statementCreateAfter(StatementProxy statement) {
JdbcDataSourceStat dataSourceStat = statement.getConnectionProxy().getDirectDataSource().getDataSourceStat();
dataSourceStat.getStatementStat().incrementCreateCounter();
super.statementCreateAfter(statement);
}
use of com.alibaba.druid.stat.JdbcDataSourceStat in project druid by alibaba.
the class StatFilter method statement_executeErrorAfter.
@Override
protected void statement_executeErrorAfter(StatementProxy statement, String sql, Throwable error) {
ConnectionProxy connection = statement.getConnectionProxy();
JdbcConnectionStat.Entry connectionCounter = getConnectionInfo(connection);
long nanos = System.nanoTime() - statement.getLastExecuteStartNano();
JdbcDataSourceStat dataSourceStat = statement.getConnectionProxy().getDirectDataSource().getDataSourceStat();
dataSourceStat.getStatementStat().error(error);
dataSourceStat.getStatementStat().afterExecute(nanos);
connectionCounter.error(error);
// SQL
JdbcSqlStat sqlStat = statement.getSqlStat();
if (sqlStat != null) {
sqlStat.decrementExecutingCount();
sqlStat.error(error);
sqlStat.addExecuteTime(statement.getLastExecuteType(), statement.isFirstResultSet(), nanos);
statement.setLastExecuteTimeNano(nanos);
}
StatFilterContext.getInstance().executeAfter(sql, nanos, error);
Profiler.release(nanos);
}
Aggregations