Search in sources :

Example 16 with DatabaseInfoAccessor

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor in project pinpoint by naver.

the class PreparedStatementExecuteQueryInterceptor method before.

@Override
public void before(Object target, Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, args);
    }
    Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    SpanEventRecorder recorder = trace.traceBlockBegin();
    try {
        DatabaseInfo databaseInfo = (target instanceof DatabaseInfoAccessor) ? ((DatabaseInfoAccessor) target)._$PINPOINT$_getDatabaseInfo() : null;
        if (databaseInfo == null) {
            databaseInfo = UnKnownDatabaseInfo.INSTANCE;
        }
        recorder.recordServiceType(databaseInfo.getExecuteQueryType());
        recorder.recordEndPoint(databaseInfo.getMultipleHost());
        recorder.recordDestinationId(databaseInfo.getDatabaseId());
        ParsingResult parsingResult = null;
        if (target instanceof ParsingResultAccessor) {
            parsingResult = ((ParsingResultAccessor) target)._$PINPOINT$_getParsingResult();
        }
        Map<Integer, String> bindValue = null;
        if (target instanceof BindValueAccessor) {
            bindValue = ((BindValueAccessor) target)._$PINPOINT$_getBindValue();
        }
        if (bindValue != null) {
            String bindString = toBindVariable(bindValue);
            recorder.recordSqlParsingResult(parsingResult, bindString);
        } else {
            recorder.recordSqlParsingResult(parsingResult);
        }
        recorder.recordApi(descriptor);
        //            trace.recordApi(apiId);
        // Need to change where to invoke clean().
        // There is cleanParameters method but it's not necessary to intercept that method.
        // iBatis intentionally does not invoke it in most cases. 
        clean(target);
    } catch (Exception e) {
        if (logger.isWarnEnabled()) {
            logger.warn(e.getMessage(), e);
        }
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) ParsingResult(com.navercorp.pinpoint.bootstrap.context.ParsingResult) UnKnownDatabaseInfo(com.navercorp.pinpoint.bootstrap.plugin.jdbc.UnKnownDatabaseInfo) DatabaseInfo(com.navercorp.pinpoint.bootstrap.context.DatabaseInfo) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) DatabaseInfoAccessor(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor) BindValueAccessor(com.navercorp.pinpoint.bootstrap.plugin.jdbc.BindValueAccessor) ParsingResultAccessor(com.navercorp.pinpoint.bootstrap.plugin.jdbc.ParsingResultAccessor)

Example 17 with DatabaseInfoAccessor

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor in project pinpoint by naver.

the class StatementExecuteUpdateInterceptor method doInBeforeTrace.

@Override
public void doInBeforeTrace(SpanEventRecorder recorder, Object target, Object[] args) {
    DatabaseInfo databaseInfo = (target instanceof DatabaseInfoAccessor) ? ((DatabaseInfoAccessor) target)._$PINPOINT$_getDatabaseInfo() : null;
    if (databaseInfo == null) {
        databaseInfo = UnKnownDatabaseInfo.INSTANCE;
    }
    recorder.recordServiceType(databaseInfo.getExecuteQueryType());
    recorder.recordEndPoint(databaseInfo.getMultipleHost());
    recorder.recordDestinationId(databaseInfo.getDatabaseId());
    recorder.recordApi(methodDescriptor);
    if (args != null && args.length > 0) {
        Object arg = args[0];
        if (arg instanceof String) {
            recorder.recordSqlInfo((String) arg);
        }
    }
}
Also used : UnKnownDatabaseInfo(com.navercorp.pinpoint.bootstrap.plugin.jdbc.UnKnownDatabaseInfo) DatabaseInfo(com.navercorp.pinpoint.bootstrap.context.DatabaseInfo) DatabaseInfoAccessor(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor)

Example 18 with DatabaseInfoAccessor

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor in project pinpoint by naver.

the class TransactionCommitInterceptor method doInAfterTrace.

@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
    DatabaseInfo databaseInfo = (target instanceof DatabaseInfoAccessor) ? ((DatabaseInfoAccessor) target)._$PINPOINT$_getDatabaseInfo() : null;
    if (databaseInfo == null) {
        databaseInfo = UnKnownDatabaseInfo.INSTANCE;
    }
    recorder.recordServiceType(databaseInfo.getType());
    recorder.recordEndPoint(databaseInfo.getMultipleHost());
    recorder.recordDestinationId(databaseInfo.getDatabaseId());
    recorder.recordApi(methodDescriptor);
    recorder.recordException(throwable);
}
Also used : UnKnownDatabaseInfo(com.navercorp.pinpoint.bootstrap.plugin.jdbc.UnKnownDatabaseInfo) DatabaseInfo(com.navercorp.pinpoint.bootstrap.context.DatabaseInfo) DatabaseInfoAccessor(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor)

Example 19 with DatabaseInfoAccessor

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor in project pinpoint by naver.

the class TransactionSetAutoCommitInterceptor method doInAfterTrace.

@Override
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
    DatabaseInfo databaseInfo = (target instanceof DatabaseInfoAccessor) ? ((DatabaseInfoAccessor) target)._$PINPOINT$_getDatabaseInfo() : null;
    if (databaseInfo == null) {
        databaseInfo = UnKnownDatabaseInfo.INSTANCE;
    }
    recorder.recordServiceType(databaseInfo.getType());
    recorder.recordEndPoint(databaseInfo.getMultipleHost());
    recorder.recordDestinationId(databaseInfo.getDatabaseId());
    recorder.recordApi(methodDescriptor, args);
    recorder.recordException(throwable);
}
Also used : UnKnownDatabaseInfo(com.navercorp.pinpoint.bootstrap.plugin.jdbc.UnKnownDatabaseInfo) DatabaseInfo(com.navercorp.pinpoint.bootstrap.context.DatabaseInfo) DatabaseInfoAccessor(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor)

Example 20 with DatabaseInfoAccessor

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor in project pinpoint by naver.

the class CallableStatementRegisterOutParameterInterceptor method doInAfterTrace.

@Override
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
    DatabaseInfo databaseInfo = (target instanceof DatabaseInfoAccessor) ? ((DatabaseInfoAccessor) target)._$PINPOINT$_getDatabaseInfo() : null;
    if (databaseInfo == null) {
        databaseInfo = UnKnownDatabaseInfo.INSTANCE;
    }
    recorder.recordServiceType(databaseInfo.getType());
    recorder.recordEndPoint(databaseInfo.getMultipleHost());
    recorder.recordDestinationId(databaseInfo.getDatabaseId());
    recorder.recordApi(methodDescriptor, args);
    recorder.recordException(throwable);
}
Also used : UnKnownDatabaseInfo(com.navercorp.pinpoint.bootstrap.plugin.jdbc.UnKnownDatabaseInfo) DatabaseInfo(com.navercorp.pinpoint.bootstrap.context.DatabaseInfo) DatabaseInfoAccessor(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor)

Aggregations

DatabaseInfoAccessor (com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor)27 UnKnownDatabaseInfo (com.navercorp.pinpoint.bootstrap.plugin.jdbc.UnKnownDatabaseInfo)24 DatabaseInfo (com.navercorp.pinpoint.bootstrap.context.DatabaseInfo)20 ParsingResultAccessor (com.navercorp.pinpoint.bootstrap.plugin.jdbc.ParsingResultAccessor)7 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)5 ParsingResult (com.navercorp.pinpoint.bootstrap.context.ParsingResult)4 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)4 DefaultDatabaseInfo (com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo)4 RegularStatement (com.datastax.driver.core.RegularStatement)2 BindValueAccessor (com.navercorp.pinpoint.bootstrap.plugin.jdbc.BindValueAccessor)2 BoundStatement (com.datastax.driver.core.BoundStatement)1 Cluster (com.datastax.driver.core.Cluster)1 Host (com.datastax.driver.core.Host)1 MethodDescriptor (com.navercorp.pinpoint.bootstrap.context.MethodDescriptor)1 TraceContext (com.navercorp.pinpoint.bootstrap.context.TraceContext)1 JdbcUrlParser (com.navercorp.pinpoint.bootstrap.plugin.jdbc.JdbcUrlParser)1 Driver (java.sql.Driver)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 Test (org.junit.Test)1