diff --git a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParser.java b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParser.java index cef0dc129667..e6074012ff91 100644 --- a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParser.java +++ b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParser.java @@ -863,11 +863,15 @@ public static DbInfo parse(String connectionUrl, Properties props) { // Make this easier and ignore case. connectionUrl = connectionUrl.toLowerCase(Locale.ROOT); - if (!connectionUrl.startsWith("jdbc:")) { + String jdbcUrl; + if (connectionUrl.startsWith("jdbc:")) { + jdbcUrl = connectionUrl.substring("jdbc:".length()); + } else if (connectionUrl.startsWith("jdbc-secretsmanager:")) { + jdbcUrl = connectionUrl.substring("jdbc-secretsmanager:".length()); + } else { return DEFAULT; } - String jdbcUrl = connectionUrl.substring("jdbc:".length()); int typeLoc = jdbcUrl.indexOf(':'); if (typeLoc < 1) { diff --git a/instrumentation/jdbc/library/src/test/groovy/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParserTest.groovy b/instrumentation/jdbc/library/src/test/groovy/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParserTest.groovy index b4048831e7cc..e6cba306684b 100644 --- a/instrumentation/jdbc/library/src/test/groovy/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParserTest.groovy +++ b/instrumentation/jdbc/library/src/test/groovy/io/opentelemetry/instrumentation/jdbc/internal/JdbcConnectionUrlParserTest.groovy @@ -219,6 +219,12 @@ class JdbcConnectionUrlParserTest extends Specification { "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" + // https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieving-secrets_jdbc.html + "jdbc-secretsmanager:mysql://example.com:50000" | null | "mysql://example.com:50000" | "mysql" | null | null | "example.com" | 50000 | null | null + "jdbc-secretsmanager:postgresql://example.com:50000/dbname" | null | "postgresql://example.com:50000" | "postgresql" | null | null | "example.com" | 50000 | null | "dbname" + "jdbc-secretsmanager:oracle:thin:@example.com:50000/ORCL" | null | "oracle:thin://example.com:50000" | "oracle" | "thin" | null | "example.com" | 50000 | "orcl" | null + "jdbc-secretsmanager:sqlserver://example.com:50000" | null | "sqlserver://example.com:50000" | "mssql" | null | null | "example.com" | 50000 | null | null + expected = DbInfo.builder().system(system).subtype(subtype).user(user).name(name).db(db).host(host).port(port).shortUrl(shortUrl).build() } }