use of org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo in project incubator-skywalking by apache.
the class URLParserTest method testParseMysqlJDBCURLWithHostAndPort.
@Test
public void testParseMysqlJDBCURLWithHostAndPort() {
ConnectionInfo connectionInfo = new URLParser().parser("jdbc:mysql//primaryhost:3307/test?profileSQL=true");
assertThat(connectionInfo.getDBType(), is("Mysql"));
assertThat(connectionInfo.getDatabaseName(), is("test"));
assertThat(connectionInfo.getDatabasePeer(), is("primaryhost:3307"));
}
use of org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo in project incubator-skywalking by apache.
the class URLParserTest method testParseOracleServiceName.
@Test
public void testParseOracleServiceName() {
ConnectionInfo connectionInfo = new URLParser().parser("jdbc:oracle:thin:@//localhost:1521/orcl");
assertThat(connectionInfo.getDBType(), is("Oracle"));
assertThat(connectionInfo.getDatabaseName(), is("orcl"));
assertThat(connectionInfo.getDatabasePeer(), is("localhost:1521"));
}
use of org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo in project incubator-skywalking by apache.
the class URLParserTest method testParseOracleTNSNameWithMultiAddress.
@Test
public void testParseOracleTNSNameWithMultiAddress() {
ConnectionInfo connectionInfo = new URLParser().parser("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL= TCP)(HOST=hostA)(PORT= 1523 ))(ADDRESS=(PROTOCOL=TCP)(HOST=hostB)(PORT= 1521 )))(SOURCE_ROUTE=yes)(CONNECT_DATA=(SERVICE_NAME=orcl)))");
assertThat(connectionInfo.getDBType(), is("Oracle"));
assertThat(connectionInfo.getDatabaseName(), is("orcl"));
assertThat(connectionInfo.getDatabasePeer(), is("hostA:1523,hostB:1521"));
}
use of org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo in project incubator-skywalking by apache.
the class URLParserTest method testParseH2JDBCURL.
@Test
public void testParseH2JDBCURL() {
ConnectionInfo connectionInfo = new URLParser().parser("jdbc:h2:tcp://localhost:8084/~/sample");
assertThat(connectionInfo.getDBType(), is("H2"));
assertThat(connectionInfo.getDatabaseName(), is("sample"));
assertThat(connectionInfo.getDatabasePeer(), is("localhost:8084"));
}
use of org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo in project incubator-skywalking by apache.
the class PreparedStatementExecuteMethodsInterceptor method beforeMethod.
@Override
public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
StatementEnhanceInfos cacheObject = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField();
ConnectionInfo connectInfo = cacheObject.getConnectionInfo();
/**
* For avoid NPE. In this particular case, Execute sql inside the {@link com.mysql.jdbc.ConnectionImpl} constructor,
* before the interceptor sets the connectionInfo.
*
* @see JDBCDriverInterceptor#afterMethod(EnhancedInstance, Method, Object[], Class[], Object)
*/
if (connectInfo != null) {
AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo.getDatabasePeer());
Tags.DB_TYPE.set(span, "sql");
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
Tags.DB_STATEMENT.set(span, cacheObject.getSql());
span.setComponent(connectInfo.getComponent());
SpanLayer.asDB(span);
}
}
Aggregations