Search in sources :

Example 16 with DatabaseInfo

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

the class CubridJdbcUrlParser method parse.

@Override
public DatabaseInfo parse(String jdbcUrl) {
    if (jdbcUrl == null) {
        logger.info("jdbcUrl may not be null");
        return UnKnownDatabaseInfo.INSTANCE;
    }
    final Matcher matcher = PREFIX_PATTERN.matcher(jdbcUrl);
    if (!matcher.find()) {
        logger.info("jdbcUrl has invalid prefix.(url:{}, prefix-pattern:{})", jdbcUrl, URL_PREFIX_PATTERN);
        return UnKnownDatabaseInfo.INSTANCE;
    }
    DatabaseInfo result = null;
    try {
        result = parse0(jdbcUrl);
    } catch (Exception e) {
        logger.info("CubridJdbcUrl parse error. url: {}, Caused: {}", jdbcUrl, e.getMessage(), e);
        result = UnKnownDatabaseInfo.createUnknownDataBase(CubridConstants.CUBRID, CubridConstants.CUBRID_EXECUTE_QUERY, jdbcUrl);
    }
    return result;
}
Also used : Matcher(java.util.regex.Matcher) UnKnownDatabaseInfo(com.navercorp.pinpoint.bootstrap.plugin.jdbc.UnKnownDatabaseInfo) DatabaseInfo(com.navercorp.pinpoint.bootstrap.context.DatabaseInfo) DefaultDatabaseInfo(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo)

Example 17 with DatabaseInfo

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

the class CubridConnectionStringParserTest method parseFailTest2.

@Test
public void parseFailTest2() {
    String cubrid = "jdbc:mysql:10.99.196.126:34001:nrdwapw:::?charset=utf-8:";
    DatabaseInfo dbInfo = parser.parse(cubrid);
    Assert.assertFalse(dbInfo.isParsingComplete());
    Assert.assertEquals(ServiceType.UNKNOWN_DB, dbInfo.getType());
}
Also used : DatabaseInfo(com.navercorp.pinpoint.bootstrap.context.DatabaseInfo) Test(org.junit.Test)

Example 18 with DatabaseInfo

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

the class CubridConnectionStringParserTest method testParse2.

@Test
public void testParse2() {
    String cubrid = "jdbc:cubrid-mysql:10.99.196.126:34001:nrdwapw:::?charset=utf-8:";
    DatabaseInfo dbInfo = parser.parse(cubrid);
    Assert.assertTrue(dbInfo.isParsingComplete());
    Assert.assertEquals(CubridConstants.CUBRID, dbInfo.getType());
    Assert.assertEquals("10.99.196.126:34001", dbInfo.getHost().get(0));
    Assert.assertEquals("nrdwapw", dbInfo.getDatabaseId());
    Assert.assertEquals("jdbc:cubrid-mysql:10.99.196.126:34001:nrdwapw:::", dbInfo.getUrl());
}
Also used : DatabaseInfo(com.navercorp.pinpoint.bootstrap.context.DatabaseInfo) Test(org.junit.Test)

Example 19 with DatabaseInfo

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

the class CubridConnectionStringParserTest method testParse3.

@Test
public void testParse3() {
    String cubrid = "jdbc:cubrid-oracle:10.99.196.126:34001:nrdwapw:::?charset=utf-8:";
    DatabaseInfo dbInfo = parser.parse(cubrid);
    Assert.assertTrue(dbInfo.isParsingComplete());
    Assert.assertEquals(CubridConstants.CUBRID, dbInfo.getType());
    Assert.assertEquals("10.99.196.126:34001", dbInfo.getHost().get(0));
    Assert.assertEquals("nrdwapw", dbInfo.getDatabaseId());
    Assert.assertEquals("jdbc:cubrid-oracle:10.99.196.126:34001:nrdwapw:::", dbInfo.getUrl());
}
Also used : DatabaseInfo(com.navercorp.pinpoint.bootstrap.context.DatabaseInfo) Test(org.junit.Test)

Example 20 with DatabaseInfo

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

the class CassandraDriverConnectInterceptor 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.
    List<String> hostList = new ArrayList<String>();
    if (target instanceof Cluster) {
        Cluster cluster = (Cluster) target;
        final Set<Host> hosts = cluster.getMetadata().getAllHosts();
        final int port = cluster.getConfiguration().getProtocolOptions().getPort();
        for (Host host : hosts) {
            final String hostAddress = host.getAddress().getHostAddress() + ":" + port;
            hostList.add(hostAddress);
        }
    }
    if (args == null) {
        return;
    }
    final String keyspace = (String) args[0];
    DatabaseInfo databaseInfo = createDatabaseInfo(keyspace, hostList);
    if (success) {
        if (recordConnection) {
            if (result instanceof DatabaseInfoAccessor) {
                ((DatabaseInfoAccessor) result)._$PINPOINT$_setDatabaseInfo(databaseInfo);
            }
        }
    }
}
Also used : UnKnownDatabaseInfo(com.navercorp.pinpoint.bootstrap.plugin.jdbc.UnKnownDatabaseInfo) DefaultDatabaseInfo(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo) DatabaseInfo(com.navercorp.pinpoint.bootstrap.context.DatabaseInfo) DatabaseInfoAccessor(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor) ArrayList(java.util.ArrayList) Cluster(com.datastax.driver.core.Cluster) Host(com.datastax.driver.core.Host)

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