use of com.navercorp.pinpoint.bootstrap.context.DatabaseInfo in project pinpoint by naver.
the class JDBCUrlParserTest method oracleRacParser1.
@Test
public void oracleRacParser1() {
// "jdbc:oracle:thin:@(Description1=(LOAD_BALANCE=on)" +
// "(ADDRESS=(PROTOCOL=TCP)(HOST=1.2.3.4) (PORT=1521))" +
// "(ADDRESS=(PROTOCOL=TCP)(HOST=1.2.3.5) (PORT=1521))" +
// "(CONNECT_DATA=(SERVICE_NAME=service)))"
String rac = "jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)" + "(ADDRESS=(PROTOCOL=TCP)(HOST=1.2.3.4) (PORT=1521))" + "(ADDRESS=(PROTOCOL=TCP)(HOST=1.2.3.5) (PORT=1522))" + "(CONNECT_DATA=(SERVICE_NAME=service)))";
DatabaseInfo dbInfo = jdbcUrlParser.parse(rac);
Assert.assertTrue(dbInfo.isParsingComplete());
Assert.assertEquals(dbInfo.getType(), OracleConstants.ORACLE);
Assert.assertEquals(dbInfo.getHost().get(0), "1.2.3.4:1521");
Assert.assertEquals(dbInfo.getHost().get(1), "1.2.3.5:1522");
Assert.assertEquals(dbInfo.getDatabaseId(), "service");
Assert.assertEquals(dbInfo.getUrl(), rac);
logger.info(dbInfo.toString());
}
use of com.navercorp.pinpoint.bootstrap.context.DatabaseInfo in project pinpoint by naver.
the class JDBCUrlParserTest method oracleParserServiceName.
@Test
public void oracleParserServiceName() {
// jdbc:oracle:thin:@hostname:port:SID
// "jdbc:oracle:thin:MYWORKSPACE/qwerty@localhost:1521:XE";
DatabaseInfo dbInfo = jdbcUrlParser.parse("jdbc:oracle:thin:@hostname:port/serviceName");
Assert.assertTrue(dbInfo.isParsingComplete());
Assert.assertEquals(dbInfo.getType(), OracleConstants.ORACLE);
Assert.assertEquals(dbInfo.getHost().get(0), "hostname:port");
Assert.assertEquals(dbInfo.getDatabaseId(), "serviceName");
Assert.assertEquals(dbInfo.getUrl(), "jdbc:oracle:thin:@hostname:port/serviceName");
logger.info(dbInfo.toString());
}
use of com.navercorp.pinpoint.bootstrap.context.DatabaseInfo in project pinpoint by naver.
the class PostgreSqlUrlParserTest method postgresqlParse3.
@Test
public void postgresqlParse3() {
DatabaseInfo dbInfo = jdbcUrlParser.parse("jdbc:postgresql://61.74.71.31/log?useUnicode=yes&characterEncoding=UTF-8");
Assert.assertTrue(dbInfo.isParsingComplete());
Assert.assertEquals(dbInfo.getType(), PostgreSqlConstants.POSTGRESQL);
Assert.assertEquals(dbInfo.getHost().get(0), "61.74.71.31");
Assert.assertEquals(dbInfo.getDatabaseId(), "log");
Assert.assertEquals(dbInfo.getUrl(), "jdbc:postgresql://61.74.71.31/log");
logger.info(dbInfo.toString());
}
use of com.navercorp.pinpoint.bootstrap.context.DatabaseInfo in project pinpoint by naver.
the class PostgreSqlUrlParserTest method postgresqlParse1.
@Test
public void postgresqlParse1() {
DatabaseInfo dbInfo = jdbcUrlParser.parse("jdbc:postgresql://ip_address:3306/database_name?useUnicode=yes&characterEncoding=UTF-8");
Assert.assertTrue(dbInfo.isParsingComplete());
Assert.assertEquals(dbInfo.getType(), PostgreSqlConstants.POSTGRESQL);
Assert.assertEquals(dbInfo.getHost().get(0), ("ip_address:3306"));
Assert.assertEquals(dbInfo.getDatabaseId(), "database_name");
Assert.assertEquals(dbInfo.getUrl(), "jdbc:postgresql://ip_address:3306/database_name");
}
use of com.navercorp.pinpoint.bootstrap.context.DatabaseInfo in project pinpoint by naver.
the class PostgreSQLConnectionCreateInterceptor 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;
}
Properties properties = getProperties(args[3]);
final String hostToConnectTo = properties.getProperty("PGHOST");
final Integer portToConnectTo = Integer.valueOf(properties.getProperty("PGPORT", DEFAULT_PORT));
final String databaseId = properties.getProperty("PGDBNAME");
// 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());
}
}
Aggregations