Fix db.system for SAP Hana and remove unnecessary code (#6401)
* Remove unnecessary code * Remove unnecessary code * Fix tests
This commit is contained in:
parent
faa367395f
commit
11a057594e
|
@ -636,7 +636,7 @@ class JdbcInstrumentationTest extends AgentInstrumentationSpecification {
|
|||
kind CLIENT
|
||||
childOf span(0)
|
||||
attributes {
|
||||
"$SemanticAttributes.DB_SYSTEM" "testdb"
|
||||
"$SemanticAttributes.DB_SYSTEM" "other_sql"
|
||||
"$SemanticAttributes.DB_STATEMENT" "testing ?"
|
||||
"$SemanticAttributes.DB_CONNECTION_STRING" "testdb://localhost"
|
||||
"$SemanticAttributes.NET_PEER_NAME" "localhost"
|
||||
|
@ -677,7 +677,7 @@ class JdbcInstrumentationTest extends AgentInstrumentationSpecification {
|
|||
kind CLIENT
|
||||
childOf span(0)
|
||||
attributes {
|
||||
"$SemanticAttributes.DB_SYSTEM" "testdb"
|
||||
"$SemanticAttributes.DB_SYSTEM" "other_sql"
|
||||
"$SemanticAttributes.DB_NAME" databaseName
|
||||
"$SemanticAttributes.DB_CONNECTION_STRING" "testdb://localhost"
|
||||
"$SemanticAttributes.DB_STATEMENT" sanitizedQuery
|
||||
|
@ -783,7 +783,7 @@ class JdbcInstrumentationTest extends AgentInstrumentationSpecification {
|
|||
kind CLIENT
|
||||
childOf span(0)
|
||||
attributes {
|
||||
"$SemanticAttributes.DB_SYSTEM" "testdb"
|
||||
"$SemanticAttributes.DB_SYSTEM" "other_sql"
|
||||
"$SemanticAttributes.DB_CONNECTION_STRING" "testdb://localhost"
|
||||
"$SemanticAttributes.DB_STATEMENT" "SELECT * FROM table"
|
||||
"$SemanticAttributes.DB_OPERATION" "SELECT"
|
||||
|
|
|
@ -55,19 +55,16 @@ public enum JdbcConnectionUrlParser {
|
|||
if (!path.isEmpty()) {
|
||||
builder.db(path);
|
||||
}
|
||||
|
||||
if (uri.getHost() != null) {
|
||||
builder.host(uri.getHost());
|
||||
}
|
||||
|
||||
if (uri.getPort() > 0) {
|
||||
builder.port(uri.getPort());
|
||||
}
|
||||
|
||||
return builder.system(uri.getScheme());
|
||||
} catch (Exception e) {
|
||||
return builder;
|
||||
logger.log(FINE, e.getMessage(), e);
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -629,13 +626,13 @@ public enum JdbcConnectionUrlParser {
|
|||
if (dbInfo.getPort() == null) {
|
||||
builder.port(DEFAULT_PORT);
|
||||
}
|
||||
return MODIFIED_URL_LIKE.doParse(jdbcUrl, builder).system(DbSystemValues.H2).subtype("tcp");
|
||||
return MODIFIED_URL_LIKE.doParse(jdbcUrl, builder).subtype("tcp");
|
||||
} else if (h2Url.startsWith("ssl:")) {
|
||||
DbInfo dbInfo = builder.build();
|
||||
if (dbInfo.getPort() == null) {
|
||||
builder.port(DEFAULT_PORT);
|
||||
}
|
||||
return MODIFIED_URL_LIKE.doParse(jdbcUrl, builder).system(DbSystemValues.H2).subtype("ssl");
|
||||
return MODIFIED_URL_LIKE.doParse(jdbcUrl, builder).subtype("ssl");
|
||||
} else {
|
||||
builder.subtype("file").host(null).port(null);
|
||||
int propLoc = h2Url.indexOf(";");
|
||||
|
@ -688,22 +685,22 @@ public enum JdbcConnectionUrlParser {
|
|||
if (dbInfo.getPort() == null) {
|
||||
builder.port(DEFAULT_PORT);
|
||||
}
|
||||
return MODIFIED_URL_LIKE.doParse(jdbcUrl, builder).system("hsqldb").subtype("hsql");
|
||||
return MODIFIED_URL_LIKE.doParse(jdbcUrl, builder).subtype("hsql");
|
||||
} else if (hsqlUrl.startsWith("hsqls:")) {
|
||||
if (dbInfo.getPort() == null) {
|
||||
builder.port(DEFAULT_PORT);
|
||||
}
|
||||
return MODIFIED_URL_LIKE.doParse(jdbcUrl, builder).system("hsqldb").subtype("hsqls");
|
||||
return MODIFIED_URL_LIKE.doParse(jdbcUrl, builder).subtype("hsqls");
|
||||
} else if (hsqlUrl.startsWith("http:")) {
|
||||
if (dbInfo.getPort() == null) {
|
||||
builder.port(80);
|
||||
}
|
||||
return MODIFIED_URL_LIKE.doParse(jdbcUrl, builder).system("hsqldb").subtype("http");
|
||||
return MODIFIED_URL_LIKE.doParse(jdbcUrl, builder).subtype("http");
|
||||
} else if (hsqlUrl.startsWith("https:")) {
|
||||
if (dbInfo.getPort() == null) {
|
||||
builder.port(443);
|
||||
}
|
||||
return MODIFIED_URL_LIKE.doParse(jdbcUrl, builder).system("hsqldb").subtype("https");
|
||||
return MODIFIED_URL_LIKE.doParse(jdbcUrl, builder).subtype("https");
|
||||
} else {
|
||||
builder.subtype("mem").host(null).port(null);
|
||||
instance = hsqlUrl;
|
||||
|
@ -969,6 +966,8 @@ public enum JdbcConnectionUrlParser {
|
|||
case "microsoft":
|
||||
case "sqlserver": // Microsoft SQL Server
|
||||
return DbSystemValues.MSSQL;
|
||||
case "sap": // SAP Hana
|
||||
return DbSystemValues.HANADB;
|
||||
default:
|
||||
return DbSystemValues.OTHER_SQL; // Unknown DBMS
|
||||
}
|
||||
|
|
|
@ -147,9 +147,9 @@ class JdbcConnectionUrlParserTest extends Specification {
|
|||
"jdbc:as400://ashost:66/asdb:user=asuser;password=PW;" | null | "as400://ashost:66" | "db2" | null | "asuser" | "ashost" | 66 | "asdb" | null
|
||||
|
||||
// https://help.sap.com/viewer/0eec0d68141541d1b07893a39944924e/2.0.03/en-US/ff15928cf5594d78b841fbbe649f04b4.html
|
||||
"jdbc:sap://sap.host" | null | "sap://sap.host" | "sap" | null | null | "sap.host" | null | null | null
|
||||
"jdbc:sap://sap.host" | stdProps | "sap://sap.host:9999" | "sap" | null | "stdUserName" | "sap.host" | 9999 | null | "stdDatabaseName"
|
||||
"jdbc:sap://sap.host:88/?databaseName=sapdb&user=sapuser&password=PW" | null | "sap://sap.host:88" | "sap" | null | "sapuser" | "sap.host" | 88 | null | "sapdb"
|
||||
"jdbc:sap://sap.host" | null | "sap://sap.host" | "hanadb" | null | null | "sap.host" | null | null | null
|
||||
"jdbc:sap://sap.host" | stdProps | "sap://sap.host:9999" | "hanadb" | null | "stdUserName" | "sap.host" | 9999 | null | "stdDatabaseName"
|
||||
"jdbc:sap://sap.host:88/?databaseName=sapdb&user=sapuser&password=PW" | null | "sap://sap.host:88" | "hanadb" | null | "sapuser" | "sap.host" | 88 | null | "sapdb"
|
||||
|
||||
// TODO:
|
||||
// "jdbc:informix-sqli://infxhost:99/infxdb:INFORMIXSERVER=infxsn;user=infxuser;password=PW" | null | "informix-sqli" | null | "infxuser" | "infxhost" | 99 | "infxdb"| null
|
||||
|
|
Loading…
Reference in New Issue