Search in sources :

Example 6 with JdbcDataSourceStat

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();
}
Also used : JdbcDataSourceStat(com.alibaba.druid.stat.JdbcDataSourceStat)

Example 7 with JdbcDataSourceStat

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);
    }
}
Also used : JdbcDataSourceStat(com.alibaba.druid.stat.JdbcDataSourceStat) JdbcStatContext(com.alibaba.druid.stat.JdbcStatContext)

Example 8 with JdbcDataSourceStat

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);
}
Also used : JdbcDataSourceStat(com.alibaba.druid.stat.JdbcDataSourceStat)

Example 9 with JdbcDataSourceStat

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);
}
Also used : JdbcDataSourceStat(com.alibaba.druid.stat.JdbcDataSourceStat)

Example 10 with JdbcDataSourceStat

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);
}
Also used : JdbcSqlStat(com.alibaba.druid.stat.JdbcSqlStat) JdbcDataSourceStat(com.alibaba.druid.stat.JdbcDataSourceStat) ConnectionProxy(com.alibaba.druid.proxy.jdbc.ConnectionProxy) JdbcConnectionStat(com.alibaba.druid.stat.JdbcConnectionStat)

Aggregations

JdbcDataSourceStat (com.alibaba.druid.stat.JdbcDataSourceStat)25 JdbcSqlStat (com.alibaba.druid.stat.JdbcSqlStat)6 SQLException (java.sql.SQLException)4 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)3 JdbcConnectionStat (com.alibaba.druid.stat.JdbcConnectionStat)3 JdbcStatContext (com.alibaba.druid.stat.JdbcStatContext)3 Connection (java.sql.Connection)3 Properties (java.util.Properties)3 ConnectionProxy (com.alibaba.druid.proxy.jdbc.ConnectionProxy)2 Savepoint (java.sql.Savepoint)2 HashMap (java.util.HashMap)2 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)2 Filter (com.alibaba.druid.filter.Filter)1 FilterChain (com.alibaba.druid.filter.FilterChain)1 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)1 StatFilter (com.alibaba.druid.filter.stat.StatFilter)1 MockDriver (com.alibaba.druid.mock.MockDriver)1 DataSourceProxy (com.alibaba.druid.proxy.jdbc.DataSourceProxy)1 DataSourceProxyConfig (com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig)1 DataSourceProxyImpl (com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl)1