Support DataDirect and Tibco Jdbc URLs
MODIFY
instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParser.java
instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParser.java
@@ -789,6 +789,35 @@ public enum JdbcConnectionUrlParser {
}
return builder.name(instance);
}
+ },
+
+ DATADIRECT("datadirect", "tibcosoftware") {
+ @Override
+ DbInfo.Builder doParse(String jdbcUrl, DbInfo.Builder builder) {
+ int typeEndIndex = jdbcUrl.indexOf(':');
+ int subtypeEndIndex = jdbcUrl.indexOf(':', typeEndIndex + 1);
+
+ if (subtypeEndIndex == -1) {
+ return builder;
+ }
+
+ String subtype = jdbcUrl.substring(typeEndIndex + 1, subtypeEndIndex);
+ builder.subtype(subtype);
+
+ if (subtype.equals("sqlserver")) {
+ builder.system(DbSystemValues.MSSQL);
+ } else if (subtype.equals("oracle")) {
+ builder.system(DbSystemValues.ORACLE);
+ } else if (subtype.equals("mysql")) {
+ builder.system(DbSystemValues.MYSQL);
+ } else if (subtype.equals("postgresql")) {
+ builder.system(DbSystemValues.POSTGRESQL);
+ } else if (subtype.equals("db2")) {
+ builder.system(DbSystemValues.DB2);
+ }
+
+ return MODIFIED_URL_LIKE.doParse(jdbcUrl, builder);
+ }
};
private static final Logger logger = Logger.getLogger(JdbcConnectionUrlParser.class.getName());

MODIFY
instrumentation/jdbc/library/src/test/groovy/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParserTest.groovy
instrumentation/jdbc/library/src/test/groovy/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParserTest.groovy
@@ -203,6 +203,21 @@ class JdbcConnectionUrlParserTest extends Specification {
"jdbc:derby:jar:/derbydb;user=derbyuser;password=pw" | null | "derby:jar:" | "derby" | "jar" | "derbyuser" | null | null | "/derbydb" | null
"jdbc:derby:jar:(~/path/to/db.jar)/other/derbydb;user=derbyuser;password=pw" | null | "derby:jar:" | "derby" | "jar" | "derbyuser" | null | null | "(~/path/to/db.jar)/other/derbydb" | null
+ // https://docs.progress.com/bundle/datadirect-connect-jdbc-51/page/URL-Formats-DataDirect-Connect-for-JDBC-Drivers.html
+ "jdbc:datadirect:sqlserver://server_name:1433;DatabaseName=dbname" | null | "datadirect:sqlserver://server_name:1433" | "mssql" | "sqlserver" | null | "server_name" | 1433 | null | "dbname"
+ "jdbc:datadirect:oracle://server_name:1521;ServiceName=your_servicename" | null | "datadirect:oracle://server_name:1521" | "oracle" | "oracle" | null | "server_name" | 1521 | null | null
+ "jdbc:datadirect:mysql://server_name:3306" | null | "datadirect:mysql://server_name:3306" | "mysql" | "mysql" | null | "server_name" | 3306 | null | null
+ "jdbc:datadirect:postgresql://server_name:5432;DatabaseName=dbname" | null | "datadirect:postgresql://server_name:5432" | "postgresql" | "postgresql" | null | "server_name" | 5432 | null | "dbname"
+ "jdbc:datadirect:db2://server_name:50000;DatabaseName=dbname" | null | "datadirect:db2://server_name:50000" | "db2" | "db2" | null | "server_name" | 50000 | null | "dbname"
+
+ // "the TIBCO JDBC drivers are based on the Progress DataDirect Connect drivers"
+ // https://community.jaspersoft.com/documentation/tibco-jasperreports-server-administrator-guide/v601/working-data-sources
+ "jdbc:tibcosoftware:sqlserver://server_name:1433;DatabaseName=dbname" | null | "tibcosoftware:sqlserver://server_name:1433" | "mssql" | "sqlserver" | null | "server_name" | 1433 | null | "dbname"
+ "jdbc:tibcosoftware:oracle://server_name:1521;ServiceName=your_servicename" | null | "tibcosoftware:oracle://server_name:1521" | "oracle" | "oracle" | null | "server_name" | 1521 | null | null
+ "jdbc:tibcosoftware:mysql://server_name:3306" | null | "tibcosoftware:mysql://server_name:3306" | "mysql" | "mysql" | null | "server_name" | 3306 | null | null
+ "jdbc:tibcosoftware:postgresql://server_name:5432;DatabaseName=dbname" | null | "tibcosoftware:postgresql://server_name:5432" | "postgresql" | "postgresql" | null | "server_name" | 5432 | null | "dbname"
+ "jdbc:tibcosoftware:db2://server_name:50000;DatabaseName=dbname" | null | "tibcosoftware:db2://server_name:50000" | "db2" | "db2" | null | "server_name" | 50000 | null | "dbname"
+
expected = DbInfo.builder().system(system).subtype(subtype).user(user).name(name).db(db).host(host).port(port).shortUrl(shortUrl).build()
}
}

Support DataDirect and Tibco Jdbc URLs (#6420)