Search in sources :

Example 26 with DatabaseInfo

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

the class MariaDBUrlParserTest method mariadbParseCookierunSlave.

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

Example 27 with DatabaseInfo

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

the class MySQLConnectionCreateInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, args, result, throwable);
    }
    if (args == null || args.length != 5) {
        return;
    }
    final String hostToConnectTo = getString(args[0]);
    final Integer portToConnectTo = getInteger(args[1]);
    final String databaseId = getString(args[3]);
    // In case of loadbalance, connectUrl is modified.
    // final String url = getString(args[4]);
    DatabaseInfo databaseInfo = null;
    if (hostToConnectTo != null && portToConnectTo != null && databaseId != null) {
        // It's dangerous to use this url directly
        databaseInfo = createDatabaseInfo(hostToConnectTo, portToConnectTo, databaseId);
        if (InterceptorUtils.isSuccess(throwable)) {
            // Set only if connection is success.
            if (target instanceof DatabaseInfoAccessor) {
                ((DatabaseInfoAccessor) target)._$PINPOINT$_setDatabaseInfo(databaseInfo);
            }
        }
    }
    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    SpanEventRecorder recorder = trace.currentSpanEventRecorder();
    // We must do this if current transaction is being recorded.
    if (databaseInfo != null) {
        recorder.recordServiceType(databaseInfo.getType());
        recorder.recordEndPoint(databaseInfo.getMultipleHost());
        recorder.recordDestinationId(databaseInfo.getDatabaseId());
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) DefaultDatabaseInfo(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo) DatabaseInfo(com.navercorp.pinpoint.bootstrap.context.DatabaseInfo) DatabaseInfoAccessor(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)

Example 28 with DatabaseInfo

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

the class MySqlUrlParserTest method mysqlParseCookierunMaster.

@Test
public void mysqlParseCookierunMaster() {
    DatabaseInfo dbInfo = jdbcUrlParser.parse("jdbc:mysql://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(), MySqlConstants.MYSQL);
    Assert.assertEquals(dbInfo.getHost().get(0), "10.115.8.209:5605");
    Assert.assertEquals(dbInfo.getDatabaseId(), "db_cookierun");
    Assert.assertEquals(dbInfo.getUrl(), "jdbc:mysql://10.115.8.209:5605/db_cookierun");
    logger.info(dbInfo.toString());
}
Also used : DatabaseInfo(com.navercorp.pinpoint.bootstrap.context.DatabaseInfo) Test(org.junit.Test)

Example 29 with DatabaseInfo

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

the class JtdsJdbcUrlParserTest method testParse6.

@Test
public void testParse6() throws Exception {
    //        jdbc:jtds:sqlserver://server[:port][/database][;property=value[;...]]
    //        jdbc:jtds:sqlserver://server/db;user=userName;password=password
    String url = "jdbc:jtds:sqlserver://10.xx.xx.xx";
    DatabaseInfo info = parser.parse(url);
    Assert.assertTrue(info.isParsingComplete());
    Assert.assertEquals(info.getType(), JtdsConstants.MSSQL);
    Assert.assertEquals(info.getMultipleHost(), "10.xx.xx.xx");
    Assert.assertEquals(info.getDatabaseId(), "");
    Assert.assertEquals(info.getUrl(), "jdbc:jtds:sqlserver://10.xx.xx.xx");
}
Also used : DatabaseInfo(com.navercorp.pinpoint.bootstrap.context.DatabaseInfo) Test(org.junit.Test)

Example 30 with DatabaseInfo

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

the class JtdsJdbcUrlParserTest method testParse1.

@Test
public void testParse1() throws Exception {
    //        jdbc:jtds:sqlserver://server[:port][/database][;property=value[;...]]
    //        jdbc:jtds:sqlserver://server/db;user=userName;password=password
    String url = "jdbc:jtds:sqlserver://10.xx.xx.xx:1433;DatabaseName=CAFECHAT;sendStringParametersAsUnicode=false;useLOBs=false;loginTimeout=3";
    DatabaseInfo info = parser.parse(url);
    Assert.assertTrue(info.isParsingComplete());
    Assert.assertEquals(info.getType(), JtdsConstants.MSSQL);
    Assert.assertEquals(info.getMultipleHost(), "10.xx.xx.xx:1433");
    Assert.assertEquals(info.getDatabaseId(), "CAFECHAT");
    Assert.assertEquals(info.getUrl(), "jdbc:jtds:sqlserver://10.xx.xx.xx:1433");
}
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