Search in sources :

Example 6 with DatabaseInfo

use of com.navercorp.pinpoint.bootstrap.context.DatabaseInfo in project pinpoint by naver.

the class TransactionRollbackInterceptor 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 7 with DatabaseInfo

use of com.navercorp.pinpoint.bootstrap.context.DatabaseInfo in project pinpoint by naver.

the class DriverConnectInterceptor method prepareAfterTrace.

@Override
protected void prepareAfterTrace(Object target, Object[] args, Object result, Throwable throwable) {
    final boolean success = InterceptorUtils.isSuccess(throwable);
    // Must not check if current transaction is trace target or not. Connection can be made by other thread.
    final String driverUrl = (String) args[0];
    DatabaseInfo databaseInfo = createDatabaseInfo(driverUrl);
    if (success) {
        if (recordConnection) {
            if (result instanceof DatabaseInfoAccessor) {
                ((DatabaseInfoAccessor) result)._$PINPOINT$_setDatabaseInfo(databaseInfo);
            }
        }
    }
}
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 8 with DatabaseInfo

use of com.navercorp.pinpoint.bootstrap.context.DatabaseInfo in project pinpoint by naver.

the class DriverConnectInterceptor method doInAfterTrace.

@Override
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
    if (recordConnection) {
        DatabaseInfo databaseInfo;
        if (result instanceof DatabaseInfoAccessor) {
            databaseInfo = ((DatabaseInfoAccessor) result)._$PINPOINT$_getDatabaseInfo();
        } else {
            databaseInfo = null;
        }
        if (databaseInfo == null) {
            databaseInfo = UnKnownDatabaseInfo.INSTANCE;
        }
        // Count database connect too because it's very heavy operation
        recorder.recordServiceType(databaseInfo.getType());
        recorder.recordEndPoint(databaseInfo.getMultipleHost());
        recorder.recordDestinationId(databaseInfo.getDatabaseId());
    }
    final String driverUrl = (String) args[0];
    // Invoking databaseInfo.getRealUrl() here is dangerous. It doesn't return real URL if it's a loadbalance connection.  
    recorder.recordApiCachedString(methodDescriptor, driverUrl, 0);
    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 9 with DatabaseInfo

use of com.navercorp.pinpoint.bootstrap.context.DatabaseInfo in project pinpoint by naver.

the class DriverConnectInterceptorV2 method prepareAfterTrace.

@Override
protected void prepareAfterTrace(Object target, Object[] args, Object result, Throwable throwable) {
    final boolean success = InterceptorUtils.isSuccess(throwable);
    // Must not check if current transaction is trace target or not. Connection can be made by other thread.
    final String driverUrl = (String) args[0];
    DatabaseInfo databaseInfo = traceContext.getJdbcContext().parseJdbcUrl(serviceType, driverUrl);
    if (success) {
        if (recordConnection) {
            if (result instanceof DatabaseInfoAccessor) {
                ((DatabaseInfoAccessor) result)._$PINPOINT$_setDatabaseInfo(databaseInfo);
            }
        }
    }
}
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 10 with DatabaseInfo

use of com.navercorp.pinpoint.bootstrap.context.DatabaseInfo in project pinpoint by naver.

the class PostgreSqlUrlParserTest method postgresqlParseCookierunMaster.

@Test
public void postgresqlParseCookierunMaster() {
    DatabaseInfo dbInfo = jdbcUrlParser.parse("jdbc:postgresql://10.115.8.209:5605/db_cookierun?useUnicode=true&characterEncoding=UTF-8&noAccessToProcedureBodies=true&autoDeserialize=true&elideSetAutoCommits=true&sessionVariables=time_zone='%2B09:00',tx_isolation='READ-COMMITTED'");
    Assert.assertTrue(dbInfo.isParsingComplete());
    Assert.assertEquals(dbInfo.getType(), PostgreSqlConstants.POSTGRESQL);
    Assert.assertEquals(dbInfo.getHost().get(0), "10.115.8.209:5605");
    Assert.assertEquals(dbInfo.getDatabaseId(), "db_cookierun");
    Assert.assertEquals(dbInfo.getUrl(), "jdbc:postgresql://10.115.8.209:5605/db_cookierun");
    logger.info(dbInfo.toString());
}
Also used : DatabaseInfo(com.navercorp.pinpoint.bootstrap.context.DatabaseInfo) Test(org.junit.Test)

Aggregations

DatabaseInfo (com.navercorp.pinpoint.bootstrap.context.DatabaseInfo)74 Test (org.junit.Test)48 UnKnownDatabaseInfo (com.navercorp.pinpoint.bootstrap.plugin.jdbc.UnKnownDatabaseInfo)25 DatabaseInfoAccessor (com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor)20 DefaultDatabaseInfo (com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo)8 ParsingResult (com.navercorp.pinpoint.bootstrap.context.ParsingResult)4 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)4 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)4 ParsingResultAccessor (com.navercorp.pinpoint.bootstrap.plugin.jdbc.ParsingResultAccessor)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 InstrumentClass (com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)1 InstrumentException (com.navercorp.pinpoint.bootstrap.instrument.InstrumentException)1 Instrumentor (com.navercorp.pinpoint.bootstrap.instrument.Instrumentor)1 TransformCallback (com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback)1 JdbcUrlParserV2 (com.navercorp.pinpoint.bootstrap.plugin.jdbc.JdbcUrlParserV2)1 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)1