From 8f288618be337be31aabaaf46280b043a2fa793a Mon Sep 17 00:00:00 2001 From: Sylvain Juge Date: Wed, 8 Sep 2021 14:26:54 +0200 Subject: [PATCH 1/4] use 'mssql' instead of 'sqlserver' --- .../agent/jdbc/helper/ConnectionMetaData.java | 2 +- .../jdbc/helper/ConnectionMetaDataTest.java | 32 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/helper/ConnectionMetaData.java b/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/helper/ConnectionMetaData.java index fd26d5ae80..c20f822526 100644 --- a/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/helper/ConnectionMetaData.java +++ b/apm-agent-plugins/apm-jdbc-plugin/src/main/java/co/elastic/apm/agent/jdbc/helper/ConnectionMetaData.java @@ -430,7 +430,7 @@ ConnectionMetaData parse(String connectionUrl, String instance, String user) { if (indexOfInstance > 0) { host = host.substring(0, indexOfInstance); } - return new ConnectionMetaData(dbVendor, host, port, instance, user); + return new ConnectionMetaData("mssql", host, port, instance, user); } }, diff --git a/apm-agent-plugins/apm-jdbc-plugin/src/test/java/co/elastic/apm/agent/jdbc/helper/ConnectionMetaDataTest.java b/apm-agent-plugins/apm-jdbc-plugin/src/test/java/co/elastic/apm/agent/jdbc/helper/ConnectionMetaDataTest.java index 5f4fd9d640..af3e4a0f86 100644 --- a/apm-agent-plugins/apm-jdbc-plugin/src/test/java/co/elastic/apm/agent/jdbc/helper/ConnectionMetaDataTest.java +++ b/apm-agent-plugins/apm-jdbc-plugin/src/test/java/co/elastic/apm/agent/jdbc/helper/ConnectionMetaDataTest.java @@ -234,23 +234,23 @@ void testMariadb() { @Test void testSqlserver() { // https://docs.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url?view=sql-server-ver15 - testUrl("jdbc:sqlserver://myhost\\instance:666", "sqlserver", "myhost", 666); - testUrl("jdbc:sqlserver://myhost\\instance:666;prop1=val1;prop2=val2", "sqlserver", "myhost", 666); - testUrl("jdbc:sqlserver://myhost:666", "sqlserver", "myhost", 666); - testUrl("jdbc:sqlserver://myhost:666;prop1=val1;prop2=val2", "sqlserver", "myhost", 666); - testUrl("jdbc:sqlserver://myhost\\instance", "sqlserver", "myhost", 1433); - testUrl("jdbc:sqlserver://myhost\\instance;prop1=val1;prop2=val2", "sqlserver", "myhost", 1433); - testUrl("jdbc:sqlserver://myhost", "sqlserver", "myhost", 1433); - testUrl("jdbc:sqlserver://myhost;prop1=val1;prop2=val2", "sqlserver", "myhost", 1433); - testUrl("jdbc:sqlserver://", "sqlserver", "localhost", 1433); - testUrl("jdbc:sqlserver://;prop1=val1;prop2=val2", "sqlserver", "localhost", 1433); - testUrl("jdbc:sqlserver://;", "sqlserver", "localhost", 1433); - testUrl("jdbc:sqlserver://;serverName=myhost", "sqlserver", "myhost", 1433); - testUrl("jdbc:sqlserver://;prop1=val1;serverName=myhost", "sqlserver", "myhost", 1433); - testUrl("jdbc:sqlserver://;serverName=myhost;prop1=val1", "sqlserver", "myhost", 1433); - testUrl("jdbc:sqlserver://;serverName=myhost\\instance;prop1=val1", "sqlserver", "myhost", 1433); + testUrl("jdbc:sqlserver://myhost\\instance:666", "mssql", "myhost", 666); + testUrl("jdbc:sqlserver://myhost\\instance:666;prop1=val1;prop2=val2", "mssql", "myhost", 666); + testUrl("jdbc:sqlserver://myhost:666", "mssql", "myhost", 666); + testUrl("jdbc:sqlserver://myhost:666;prop1=val1;prop2=val2", "mssql", "myhost", 666); + testUrl("jdbc:sqlserver://myhost\\instance", "mssql", "myhost", 1433); + testUrl("jdbc:sqlserver://myhost\\instance;prop1=val1;prop2=val2", "mssql", "myhost", 1433); + testUrl("jdbc:sqlserver://myhost", "mssql", "myhost", 1433); + testUrl("jdbc:sqlserver://myhost;prop1=val1;prop2=val2", "mssql", "myhost", 1433); + testUrl("jdbc:sqlserver://", "mssql", "localhost", 1433); + testUrl("jdbc:sqlserver://;prop1=val1;prop2=val2", "mssql", "localhost", 1433); + testUrl("jdbc:sqlserver://;", "mssql", "localhost", 1433); + testUrl("jdbc:sqlserver://;serverName=myhost", "mssql", "myhost", 1433); + testUrl("jdbc:sqlserver://;prop1=val1;serverName=myhost", "mssql", "myhost", 1433); + testUrl("jdbc:sqlserver://;serverName=myhost;prop1=val1", "mssql", "myhost", 1433); + testUrl("jdbc:sqlserver://;serverName=myhost\\instance;prop1=val1", "mssql", "myhost", 1433); testUrl("jdbc:sqlserver://;serverName=3ffe:8311:eeee:f70f:0:5eae:10.203.31.9\\instance;prop1=val1", - "sqlserver", "3ffe:8311:eeee:f70f:0:5eae:10.203.31.9", 1433); + "mssql", "3ffe:8311:eeee:f70f:0:5eae:10.203.31.9", 1433); } @Test From 9d4ddf8b93964fae910fe36d83eea9b53c9639a0 Mon Sep 17 00:00:00 2001 From: Sylvain Juge Date: Wed, 8 Sep 2021 15:14:52 +0200 Subject: [PATCH 2/4] fix integration tests --- .../src/test/resources/json-specs/span_types.json | 6 +++--- .../src/test/java/co/elastic/apm/agent/jdbc/JdbcDbIT.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apm-agent-core/src/test/resources/json-specs/span_types.json b/apm-agent-core/src/test/resources/json-specs/span_types.json index 18189088a9..b60c3730d2 100644 --- a/apm-agent-core/src/test/resources/json-specs/span_types.json +++ b/apm-agent-core/src/test/resources/json-specs/span_types.json @@ -141,7 +141,8 @@ "mssql": { "__description": "Microsoft SQL Server", "__used_by": [ - "nodejs" + "nodejs", + "java" ] }, "mysql": { @@ -183,9 +184,8 @@ ] }, "sqlserver": { - "__description": "Microsoft SQL Server", + "__description": "Microsoft SQL Server (deprecated, use mssql instead)", "__used_by": [ - "java" ] }, "unknown": { diff --git a/apm-agent-plugins/apm-jdbc-plugin/src/test/java/co/elastic/apm/agent/jdbc/JdbcDbIT.java b/apm-agent-plugins/apm-jdbc-plugin/src/test/java/co/elastic/apm/agent/jdbc/JdbcDbIT.java index 5cdae8a581..8457228e2f 100644 --- a/apm-agent-plugins/apm-jdbc-plugin/src/test/java/co/elastic/apm/agent/jdbc/JdbcDbIT.java +++ b/apm-agent-plugins/apm-jdbc-plugin/src/test/java/co/elastic/apm/agent/jdbc/JdbcDbIT.java @@ -42,7 +42,7 @@ public static Iterable data() { {"jdbc:tc:postgresql:9://hostname/databasename", "postgresql"}, {"jdbc:tc:postgresql:10://hostname/databasename", "postgresql"}, {"jdbc:tc:mariadb:10://hostname/databasename", "mariadb"}, - {"jdbc:tc:sqlserver:2017-CU12://hostname/databasename", "sqlserver"}, + {"jdbc:tc:sqlserver:2017-CU12://hostname/databasename", "mssql"}, {"jdbc:tc:db2:11.5.0.0a://hostname/databasename", "db2"}, {"jdbc:tc:oracle://hostname/databasename", "oracle"}, }); From 2bd796c80128beaf7d36943bdf846b859b6e420c Mon Sep 17 00:00:00 2001 From: Sylvain Juge Date: Wed, 8 Sep 2021 15:16:10 +0200 Subject: [PATCH 3/4] fix typo --- .../src/test/java/co/elastic/apm/agent/MockReporter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/MockReporter.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/MockReporter.java index 1abddfb484..d415316713 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/MockReporter.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/MockReporter.java @@ -226,7 +226,7 @@ private void verifySpanType(Span span) { } } else { if (!allowUnlistedSubtype && hasSubtypes) { - getMandatoryJson(subTypesJson, subType, String.format("span subtype '%s' is not allowed by the sped for type '%s'", subType, type)); + getMandatoryJson(subTypesJson, subType, String.format("span subtype '%s' is not allowed by the spec for type '%s'", subType, type)); } } From cc34a71bd5cc8fd56a205245707d96dd43c81b63 Mon Sep 17 00:00:00 2001 From: Sylvain Juge Date: Mon, 13 Sep 2021 11:24:58 +0200 Subject: [PATCH 4/4] update changelog skip ci --- CHANGELOG.asciidoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 9e47bf7855..a01f9a42aa 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -23,6 +23,10 @@ endif::[] [[release-notes-1.26.0]] ==== 1.26.0 - YYYY/MM/DD +===== Potentially breaking changes +* If you rely on Database span subtype and use Microsoft SQL Server, the span subtype has been changed from `sqlserver` +to `mssql` to align with other agents. + [float] ===== Features * Improved naming for Spring controllers - {pull}1906[#1906] @@ -62,6 +66,7 @@ user to configure an arbitrary agent version that will be downloaded from maven * Fix gRPC non-terminated (therefore non-reported) client spans - {pull}2067[#2067] * Fix Webflux response status code - {pull}1948[#1948] * Ensure path filtering is applied when Servlet path is not available - {pull}2099[#2099] +* Align span subtype for MS SqlServer - {pull}2112[#2112] [float] ===== Refactorings