From 11d051a5e00cecb79fd4b66cc72b7a2249e00694 Mon Sep 17 00:00:00 2001 From: Rasmus Kuusmann Date: Tue, 31 Oct 2023 22:38:28 +0200 Subject: [PATCH] Add support for System.Data.SqlClient (Nuget package) (#3058) --- CHANGELOG.md | 3 + OpenTelemetry.AutoInstrumentation.sln | 77 +++++---- build/LibraryVersions.g.cs | 9 +- docs/config.md | 62 ++++---- .../Initializers/SqlClientInitializer.cs | 1 + test/Directory.Packages.props | 1 + test/IntegrationTests/LibraryVersions.g.cs | 10 +- .../SqlClientMicrosoftTests.cs | 6 +- .../SqlClientSystemDataTests.cs | 2 +- test/IntegrationTests/SqlClientSystemTests.cs | 56 +++++++ .../Program.cs | 5 +- ...estApplication.SqlClient.Microsoft.csproj} | 0 .../Program.cs | 5 +- ...tion.SqlClient.System.NetFramework.csproj} | 0 .../Program.cs | 150 ++++++++++++++++++ .../TestApplication.SqlClient.System.csproj | 7 + .../PackageVersionDefinitions.cs | 15 +- 17 files changed, 338 insertions(+), 71 deletions(-) create mode 100644 test/IntegrationTests/SqlClientSystemTests.cs rename test/test-applications/integrations/{TestApplication.SqlClient => TestApplication.SqlClient.Microsoft}/Program.cs (96%) rename test/test-applications/integrations/{TestApplication.SqlClient/TestApplication.SqlClient.csproj => TestApplication.SqlClient.Microsoft/TestApplication.SqlClient.Microsoft.csproj} (100%) rename test/test-applications/integrations/{TestApplication.SqlClient.NetFramework => TestApplication.SqlClient.System.NetFramework}/Program.cs (96%) rename test/test-applications/integrations/{TestApplication.SqlClient.NetFramework/TestApplication.SqlClient.NetFramework.csproj => TestApplication.SqlClient.System.NetFramework/TestApplication.SqlClient.System.NetFramework.csproj} (100%) create mode 100644 test/test-applications/integrations/TestApplication.SqlClient.System/Program.cs create mode 100644 test/test-applications/integrations/TestApplication.SqlClient.System/TestApplication.SqlClient.System.csproj diff --git a/CHANGELOG.md b/CHANGELOG.md index 58ea67911f..d385bcfff9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ This component adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.h ### Added +- Added support for [System.Data.SqlClient](https://www.nuget.org/packages/System.Data.SqlClient/) + (NuGet package) traces instrumentation from `4.8.5`. + ### Changed ### Dependency updates diff --git a/OpenTelemetry.AutoInstrumentation.sln b/OpenTelemetry.AutoInstrumentation.sln index eb28835973..7ce3b0beea 100644 --- a/OpenTelemetry.AutoInstrumentation.sln +++ b/OpenTelemetry.AutoInstrumentation.sln @@ -101,8 +101,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.Http", "tes EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.MongoDB", "test\test-applications\integrations\TestApplication.MongoDB\TestApplication.MongoDB.csproj", "{3B77F975-BF66-4218-9982-F48D3271DDFE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.SqlClient", "test\test-applications\integrations\TestApplication.SqlClient\TestApplication.SqlClient.csproj", "{2120CFA2-9D16-45F0-A333-B0385C371509}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.Plugins", "test\test-applications\integrations\TestApplication.Plugins\TestApplication.Plugins.csproj", "{42BABA6C-1954-4F52-85C8-D336C00F06D9}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.Npgsql", "test\test-applications\integrations\TestApplication.Npgsql\TestApplication.Npgsql.csproj", "{DC54F01E-1D5C-4ECF-B5B9-14EECD2B4CF6}" @@ -141,8 +139,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.Modules", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.Http.NetFramework", "test\test-applications\integrations\TestApplication.Http.NetFramework\TestApplication.Http.NetFramework.csproj", "{5D0FECF8-1954-449D-8C42-5373D91154FA}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.SqlClient.NetFramework", "test\test-applications\integrations\TestApplication.SqlClient.NetFramework\TestApplication.SqlClient.NetFramework.csproj", "{C5EB9F63-DE06-4444-A0DB-08F1CAC07B42}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.Client", "examples\demo\Client\Examples.Client.csproj", "{6FCD22A7-E6DD-4452-8B0B-95A4D726AFA8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.Service", "examples\demo\Service\Examples.Service.csproj", "{8BBF3519-CE93-4213-9AA0-8F5DEF3C50B2}" @@ -205,7 +201,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.Wcf.Client. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.MinimalApi", "test\test-applications\integrations\TestApplication.MinimalApi\TestApplication.MinimalApi.csproj", "{803A3DD1-016E-4713-8066-A1C81A6ADBA3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApplication.Worker", "test\test-applications\integrations\TestApplication.Worker\TestApplication.Worker.csproj", "{E04065C2-0512-41C6-A428-AC85342B3D03}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.Worker", "test\test-applications\integrations\TestApplication.Worker\TestApplication.Worker.csproj", "{E04065C2-0512-41C6-A428-AC85342B3D03}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.SqlClient.System.NetFramework", "test\test-applications\integrations\TestApplication.SqlClient.System.NetFramework\TestApplication.SqlClient.System.NetFramework.csproj", "{D6720242-70E4-4C62-95BE-AA11944AE0DE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.SqlClient.System", "test\test-applications\integrations\TestApplication.SqlClient.System\TestApplication.SqlClient.System.csproj", "{3E53C72E-7711-4BD2-942C-4CEA895D2F98}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.SqlClient.Microsoft", "test\test-applications\integrations\TestApplication.SqlClient.Microsoft\TestApplication.SqlClient.Microsoft.csproj", "{C8DD1858-9C26-419F-9DE2-8E06F988EC66}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -439,18 +441,6 @@ Global {3B77F975-BF66-4218-9982-F48D3271DDFE}.Release|x64.Build.0 = Release|x64 {3B77F975-BF66-4218-9982-F48D3271DDFE}.Release|x86.ActiveCfg = Release|x86 {3B77F975-BF66-4218-9982-F48D3271DDFE}.Release|x86.Build.0 = Release|x86 - {2120CFA2-9D16-45F0-A333-B0385C371509}.Debug|Any CPU.ActiveCfg = Debug|x64 - {2120CFA2-9D16-45F0-A333-B0385C371509}.Debug|Any CPU.Build.0 = Debug|x64 - {2120CFA2-9D16-45F0-A333-B0385C371509}.Debug|x64.ActiveCfg = Debug|x64 - {2120CFA2-9D16-45F0-A333-B0385C371509}.Debug|x64.Build.0 = Debug|x64 - {2120CFA2-9D16-45F0-A333-B0385C371509}.Debug|x86.ActiveCfg = Debug|x86 - {2120CFA2-9D16-45F0-A333-B0385C371509}.Debug|x86.Build.0 = Debug|x86 - {2120CFA2-9D16-45F0-A333-B0385C371509}.Release|Any CPU.ActiveCfg = Release|x64 - {2120CFA2-9D16-45F0-A333-B0385C371509}.Release|Any CPU.Build.0 = Release|x64 - {2120CFA2-9D16-45F0-A333-B0385C371509}.Release|x64.ActiveCfg = Release|x64 - {2120CFA2-9D16-45F0-A333-B0385C371509}.Release|x64.Build.0 = Release|x64 - {2120CFA2-9D16-45F0-A333-B0385C371509}.Release|x86.ActiveCfg = Release|x86 - {2120CFA2-9D16-45F0-A333-B0385C371509}.Release|x86.Build.0 = Release|x86 {42BABA6C-1954-4F52-85C8-D336C00F06D9}.Debug|Any CPU.ActiveCfg = Debug|x64 {42BABA6C-1954-4F52-85C8-D336C00F06D9}.Debug|Any CPU.Build.0 = Debug|x64 {42BABA6C-1954-4F52-85C8-D336C00F06D9}.Debug|x64.ActiveCfg = Debug|x64 @@ -643,18 +633,6 @@ Global {5D0FECF8-1954-449D-8C42-5373D91154FA}.Release|x64.Build.0 = Release|x64 {5D0FECF8-1954-449D-8C42-5373D91154FA}.Release|x86.ActiveCfg = Release|x86 {5D0FECF8-1954-449D-8C42-5373D91154FA}.Release|x86.Build.0 = Release|x86 - {C5EB9F63-DE06-4444-A0DB-08F1CAC07B42}.Debug|Any CPU.ActiveCfg = Debug|x64 - {C5EB9F63-DE06-4444-A0DB-08F1CAC07B42}.Debug|Any CPU.Build.0 = Debug|x64 - {C5EB9F63-DE06-4444-A0DB-08F1CAC07B42}.Debug|x64.ActiveCfg = Debug|x64 - {C5EB9F63-DE06-4444-A0DB-08F1CAC07B42}.Debug|x64.Build.0 = Debug|x64 - {C5EB9F63-DE06-4444-A0DB-08F1CAC07B42}.Debug|x86.ActiveCfg = Debug|x86 - {C5EB9F63-DE06-4444-A0DB-08F1CAC07B42}.Debug|x86.Build.0 = Debug|x86 - {C5EB9F63-DE06-4444-A0DB-08F1CAC07B42}.Release|Any CPU.ActiveCfg = Release|x64 - {C5EB9F63-DE06-4444-A0DB-08F1CAC07B42}.Release|Any CPU.Build.0 = Release|x64 - {C5EB9F63-DE06-4444-A0DB-08F1CAC07B42}.Release|x64.ActiveCfg = Release|x64 - {C5EB9F63-DE06-4444-A0DB-08F1CAC07B42}.Release|x64.Build.0 = Release|x64 - {C5EB9F63-DE06-4444-A0DB-08F1CAC07B42}.Release|x86.ActiveCfg = Release|x86 - {C5EB9F63-DE06-4444-A0DB-08F1CAC07B42}.Release|x86.Build.0 = Release|x86 {6FCD22A7-E6DD-4452-8B0B-95A4D726AFA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6FCD22A7-E6DD-4452-8B0B-95A4D726AFA8}.Debug|Any CPU.Build.0 = Debug|Any CPU {6FCD22A7-E6DD-4452-8B0B-95A4D726AFA8}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -991,6 +969,42 @@ Global {E04065C2-0512-41C6-A428-AC85342B3D03}.Release|x64.Build.0 = Release|x64 {E04065C2-0512-41C6-A428-AC85342B3D03}.Release|x86.ActiveCfg = Release|x86 {E04065C2-0512-41C6-A428-AC85342B3D03}.Release|x86.Build.0 = Release|x86 + {D6720242-70E4-4C62-95BE-AA11944AE0DE}.Debug|Any CPU.ActiveCfg = Debug|x64 + {D6720242-70E4-4C62-95BE-AA11944AE0DE}.Debug|Any CPU.Build.0 = Debug|x64 + {D6720242-70E4-4C62-95BE-AA11944AE0DE}.Debug|x64.ActiveCfg = Debug|x64 + {D6720242-70E4-4C62-95BE-AA11944AE0DE}.Debug|x64.Build.0 = Debug|x64 + {D6720242-70E4-4C62-95BE-AA11944AE0DE}.Debug|x86.ActiveCfg = Debug|x86 + {D6720242-70E4-4C62-95BE-AA11944AE0DE}.Debug|x86.Build.0 = Debug|x86 + {D6720242-70E4-4C62-95BE-AA11944AE0DE}.Release|Any CPU.ActiveCfg = Release|x64 + {D6720242-70E4-4C62-95BE-AA11944AE0DE}.Release|Any CPU.Build.0 = Release|x64 + {D6720242-70E4-4C62-95BE-AA11944AE0DE}.Release|x64.ActiveCfg = Release|x64 + {D6720242-70E4-4C62-95BE-AA11944AE0DE}.Release|x64.Build.0 = Release|x64 + {D6720242-70E4-4C62-95BE-AA11944AE0DE}.Release|x86.ActiveCfg = Release|x86 + {D6720242-70E4-4C62-95BE-AA11944AE0DE}.Release|x86.Build.0 = Release|x86 + {3E53C72E-7711-4BD2-942C-4CEA895D2F98}.Debug|Any CPU.ActiveCfg = Debug|x64 + {3E53C72E-7711-4BD2-942C-4CEA895D2F98}.Debug|Any CPU.Build.0 = Debug|x64 + {3E53C72E-7711-4BD2-942C-4CEA895D2F98}.Debug|x64.ActiveCfg = Debug|x64 + {3E53C72E-7711-4BD2-942C-4CEA895D2F98}.Debug|x64.Build.0 = Debug|x64 + {3E53C72E-7711-4BD2-942C-4CEA895D2F98}.Debug|x86.ActiveCfg = Debug|x86 + {3E53C72E-7711-4BD2-942C-4CEA895D2F98}.Debug|x86.Build.0 = Debug|x86 + {3E53C72E-7711-4BD2-942C-4CEA895D2F98}.Release|Any CPU.ActiveCfg = Release|x64 + {3E53C72E-7711-4BD2-942C-4CEA895D2F98}.Release|Any CPU.Build.0 = Release|x64 + {3E53C72E-7711-4BD2-942C-4CEA895D2F98}.Release|x64.ActiveCfg = Release|x64 + {3E53C72E-7711-4BD2-942C-4CEA895D2F98}.Release|x64.Build.0 = Release|x64 + {3E53C72E-7711-4BD2-942C-4CEA895D2F98}.Release|x86.ActiveCfg = Release|x86 + {3E53C72E-7711-4BD2-942C-4CEA895D2F98}.Release|x86.Build.0 = Release|x86 + {C8DD1858-9C26-419F-9DE2-8E06F988EC66}.Debug|Any CPU.ActiveCfg = Debug|x64 + {C8DD1858-9C26-419F-9DE2-8E06F988EC66}.Debug|Any CPU.Build.0 = Debug|x64 + {C8DD1858-9C26-419F-9DE2-8E06F988EC66}.Debug|x64.ActiveCfg = Debug|x64 + {C8DD1858-9C26-419F-9DE2-8E06F988EC66}.Debug|x64.Build.0 = Debug|x64 + {C8DD1858-9C26-419F-9DE2-8E06F988EC66}.Debug|x86.ActiveCfg = Debug|x86 + {C8DD1858-9C26-419F-9DE2-8E06F988EC66}.Debug|x86.Build.0 = Debug|x86 + {C8DD1858-9C26-419F-9DE2-8E06F988EC66}.Release|Any CPU.ActiveCfg = Release|x64 + {C8DD1858-9C26-419F-9DE2-8E06F988EC66}.Release|Any CPU.Build.0 = Release|x64 + {C8DD1858-9C26-419F-9DE2-8E06F988EC66}.Release|x64.ActiveCfg = Release|x64 + {C8DD1858-9C26-419F-9DE2-8E06F988EC66}.Release|x64.Build.0 = Release|x64 + {C8DD1858-9C26-419F-9DE2-8E06F988EC66}.Release|x86.ActiveCfg = Release|x86 + {C8DD1858-9C26-419F-9DE2-8E06F988EC66}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1019,7 +1033,6 @@ Global {065FEB4E-A99E-4A59-8112-1CB30CF794F9} = {5C915382-C886-457D-8641-9E766D8E5A17} {4E17BE29-B227-41D8-97FE-26F674951E26} = {E409ADD3-9574-465C-AB09-4324D205CC7C} {3B77F975-BF66-4218-9982-F48D3271DDFE} = {E409ADD3-9574-465C-AB09-4324D205CC7C} - {2120CFA2-9D16-45F0-A333-B0385C371509} = {E409ADD3-9574-465C-AB09-4324D205CC7C} {42BABA6C-1954-4F52-85C8-D336C00F06D9} = {E409ADD3-9574-465C-AB09-4324D205CC7C} {DC54F01E-1D5C-4ECF-B5B9-14EECD2B4CF6} = {E409ADD3-9574-465C-AB09-4324D205CC7C} {CB4EA9F4-EE1B-4009-B3CD-215DCE8BE214} = {82A3CE96-0935-45E5-A9AA-A93A5B63500B} @@ -1036,7 +1049,6 @@ Global {06664166-35D6-484D-9171-DCB99D1D310A} = {E409ADD3-9574-465C-AB09-4324D205CC7C} {F8C3A1FF-2333-45C8-9174-75F12526DFDD} = {E409ADD3-9574-465C-AB09-4324D205CC7C} {5D0FECF8-1954-449D-8C42-5373D91154FA} = {E409ADD3-9574-465C-AB09-4324D205CC7C} - {C5EB9F63-DE06-4444-A0DB-08F1CAC07B42} = {E409ADD3-9574-465C-AB09-4324D205CC7C} {6FCD22A7-E6DD-4452-8B0B-95A4D726AFA8} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A} {8BBF3519-CE93-4213-9AA0-8F5DEF3C50B2} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A} {ACEB118B-767E-459F-AFD3-A52ED4ED08C6} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A} @@ -1066,6 +1078,9 @@ Global {EDE168E0-DBCD-4DE3-B55A-4B633ED6565E} = {E409ADD3-9574-465C-AB09-4324D205CC7C} {803A3DD1-016E-4713-8066-A1C81A6ADBA3} = {E409ADD3-9574-465C-AB09-4324D205CC7C} {E04065C2-0512-41C6-A428-AC85342B3D03} = {E409ADD3-9574-465C-AB09-4324D205CC7C} + {D6720242-70E4-4C62-95BE-AA11944AE0DE} = {E409ADD3-9574-465C-AB09-4324D205CC7C} + {3E53C72E-7711-4BD2-942C-4CEA895D2F98} = {E409ADD3-9574-465C-AB09-4324D205CC7C} + {C8DD1858-9C26-419F-9DE2-8E06F988EC66} = {E409ADD3-9574-465C-AB09-4324D205CC7C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {160A1D00-1F5B-40F8-A155-621B4459D78F} diff --git a/build/LibraryVersions.g.cs b/build/LibraryVersions.g.cs index 0cff21c8f0..12ed68a3df 100644 --- a/build/LibraryVersions.g.cs +++ b/build/LibraryVersions.g.cs @@ -72,7 +72,7 @@ public static class LibraryVersion } }, { - "TestApplication.SqlClient", + "TestApplication.SqlClient.Microsoft", new List { new("1.1.4"), @@ -82,6 +82,13 @@ public static class LibraryVersion new("5.1.2"), } }, + { + "TestApplication.SqlClient.System", + new List + { + new("4.8.5"), + } + }, { "TestApplication.MongoDB", new List diff --git a/docs/config.md b/docs/config.md index 7668ae2dae..6486614287 100644 --- a/docs/config.md +++ b/docs/config.md @@ -124,28 +124,28 @@ for example `TRACES`, and `{0}` is the case-sensitive name of the instrumentatio Traces are stable, but particular instrumentation are in Experimental status due to lack of stable semantic convention. -| ID | Instrumented library | Supported versions | Instrumentation type | Status | -|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|----------------------|-----------------------------------------------------------------------------------------------------------------------------------| -| `ASPNET` | ASP.NET (.NET Framework) MVC / WebApi \[1\] **Not supported on .NET** | * | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `ASPNETCORE` | ASP.NET Core **Not supported on .NET Framework** | * | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `AZURE` | [Azure SDK](https://azure.github.io/azure-sdk/releases/latest/index.html) | \[2\] | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `ELASTICSEARCH` | [Elastic.Clients.Elasticsearch](https://www.nuget.org/packages/Elastic.Clients.Elasticsearch) | * \[3\] | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `ELASTICTRANSPORT` | [Elastic.Transport](https://www.nuget.org/packages/Elastic.Transport) | ≥0.4.16 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `ENTITYFRAMEWORKCORE` | [Microsoft.EntityFrameworkCore](https://www.nuget.org/packages/) **Not supported on .NET Framework** | ≥6.0.12 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `GRAPHQL` | [GraphQL](https://www.nuget.org/packages/GraphQL) **Not supported on .NET Framework** | ≥7.5.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `GRPCNETCLIENT` | [Grpc.Net.Client](https://www.nuget.org/packages/Grpc.Net.Client) | ≥2.52.0 & < 3.0.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `HTTPCLIENT` | [System.Net.Http.HttpClient](https://docs.microsoft.com/dotnet/api/system.net.http.httpclient) and [System.Net.HttpWebRequest](https://docs.microsoft.com/dotnet/api/system.net.httpwebrequest) | * | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `QUARTZ` | [Quartz](https://www.nuget.org/packages/Quartz) **Not supported on .NET Framework 4.7.1 and older** | ≥3.4.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `MASSTRANSIT` | [MassTransit](https://www.nuget.org/packages/MassTransit) **Not supported on .NET Framework** | ≥8.0.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `MONGODB` | [MongoDB.Driver.Core](https://www.nuget.org/packages/MongoDB.Driver.Core) | ≥2.13.3 & < 3.0.0 | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `MYSQLCONNECTOR` | [MySqlConnector](https://www.nuget.org/packages/MySqlConnector) | ≥2.0.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `MYSQLDATA` | [MySql.Data](https://www.nuget.org/packages/MySql.Data) **Not supported on .NET Framework** | ≥8.1.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `NPGSQL` | [Npgsql](https://www.nuget.org/packages/Npgsql) | ≥6.0.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `NSERVICEBUS` | [NServiceBus](https://www.nuget.org/packages/NServiceBus) | ≥8.0.0 | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `SQLCLIENT` | [Microsoft.Data.SqlClient](https://www.nuget.org/packages/Microsoft.Data.SqlClient) and [System.Data.SqlClient](https://www.nuget.org/packages/System.Data.SqlClient) | * \[4\] | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `STACKEXCHANGEREDIS` | [StackExchange.Redis](https://www.nuget.org/packages/StackExchange.Redis) **Not supported on .NET Framework** | ≥2.0.405 < 3.0.0 | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `WCFCLIENT` | WCF | * | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `WCFSERVICE` | WCF **Not supported on .NET**. | * | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| ID | Instrumented library | Supported versions | Instrumentation type | Status | +|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|----------------------|-----------------------------------------------------------------------------------------------------------------------------------| +| `ASPNET` | ASP.NET (.NET Framework) MVC / WebApi \[1\] **Not supported on .NET** | * | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `ASPNETCORE` | ASP.NET Core **Not supported on .NET Framework** | * | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `AZURE` | [Azure SDK](https://azure.github.io/azure-sdk/releases/latest/index.html) | \[2\] | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `ELASTICSEARCH` | [Elastic.Clients.Elasticsearch](https://www.nuget.org/packages/Elastic.Clients.Elasticsearch) | * \[3\] | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `ELASTICTRANSPORT` | [Elastic.Transport](https://www.nuget.org/packages/Elastic.Transport) | ≥0.4.16 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `ENTITYFRAMEWORKCORE` | [Microsoft.EntityFrameworkCore](https://www.nuget.org/packages/) **Not supported on .NET Framework** | ≥6.0.12 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `GRAPHQL` | [GraphQL](https://www.nuget.org/packages/GraphQL) **Not supported on .NET Framework** | ≥7.5.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `GRPCNETCLIENT` | [Grpc.Net.Client](https://www.nuget.org/packages/Grpc.Net.Client) | ≥2.52.0 & < 3.0.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `HTTPCLIENT` | [System.Net.Http.HttpClient](https://docs.microsoft.com/dotnet/api/system.net.http.httpclient) and [System.Net.HttpWebRequest](https://docs.microsoft.com/dotnet/api/system.net.httpwebrequest) | * | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `QUARTZ` | [Quartz](https://www.nuget.org/packages/Quartz) **Not supported on .NET Framework 4.7.1 and older** | ≥3.4.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `MASSTRANSIT` | [MassTransit](https://www.nuget.org/packages/MassTransit) **Not supported on .NET Framework** | ≥8.0.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `MONGODB` | [MongoDB.Driver.Core](https://www.nuget.org/packages/MongoDB.Driver.Core) | ≥2.13.3 & < 3.0.0 | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `MYSQLCONNECTOR` | [MySqlConnector](https://www.nuget.org/packages/MySqlConnector) | ≥2.0.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `MYSQLDATA` | [MySql.Data](https://www.nuget.org/packages/MySql.Data) **Not supported on .NET Framework** | ≥8.1.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `NPGSQL` | [Npgsql](https://www.nuget.org/packages/Npgsql) | ≥6.0.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `NSERVICEBUS` | [NServiceBus](https://www.nuget.org/packages/NServiceBus) | ≥8.0.0 | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `SQLCLIENT` | [Microsoft.Data.SqlClient](https://www.nuget.org/packages/Microsoft.Data.SqlClient), [System.Data.SqlClient](https://www.nuget.org/packages/System.Data.SqlClient) and `System.Data` (shipped with .NET Framework) | * \[4\] | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `STACKEXCHANGEREDIS` | [StackExchange.Redis](https://www.nuget.org/packages/StackExchange.Redis) **Not supported on .NET Framework** | ≥2.0.405 < 3.0.0 | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `WCFCLIENT` | WCF | * | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `WCFSERVICE` | WCF **Not supported on .NET**. | * | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | \[1\]: Only integrated pipeline mode is supported. @@ -154,7 +154,9 @@ due to lack of stable semantic convention. \[3\]: `Elastic.Clients.Elasticsearch` version ≥8.0.0 and <8.10.0. Version ≥8.10.0 is supported by `Elastic.Transport` instrumentation. -\[4\]: Microsoft.Data.SqlClient v3.* is not supported on .NET Framework, due to [issue](https://github.com/open-telemetry/opentelemetry-dotnet/issues/4243). +\[4\]: `Microsoft.Data.SqlClient` v3.* is not supported on .NET Framework, + due to [issue](https://github.com/open-telemetry/opentelemetry-dotnet/issues/4243). + `System.Data.SqlClient` is supported from version 4.8.5. ### Metrics instrumentations @@ -162,14 +164,14 @@ due to lack of stable semantic convention. Metrics are stable, but particular instrumentation are in Experimental status due to lack of stable semantic convention. -| ID | Instrumented library | Documentation | Supported versions | Instrumentation type | Status | -|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|----------------------|-----------------------------------------------------------------------------------------------------------------------------------| +| ID | Instrumented library | Documentation | Supported versions | Instrumentation type | Status | +|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|----------------------|-----------------------------------------------------------------------------------------------------------------------------------| | `ASPNET` | ASP.NET Framework \[1\] **Not supported on .NET** | [ASP.NET metrics](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.AspNet-1.6.0-beta.1/src/OpenTelemetry.Instrumentation.AspNet/README.md#list-of-metrics-produced) | * | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `ASPNETCORE` | ASP.NET Core \[2\] **Not supported on .NET Framework** | [ASP.NET Core metrics](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.5.0/src/OpenTelemetry.Instrumentation.AspNetCore/README.md#list-of-metrics-produced) | * | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `HTTPCLIENT` | [System.Net.Http.HttpClient](https://docs.microsoft.com/dotnet/api/system.net.http.httpclient) and [System.Net.HttpWebRequest](https://docs.microsoft.com/dotnet/api/system.net.httpwebrequest) | [HttpClient metrics](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.5.0/src/OpenTelemetry.Instrumentation.Http/README.md#list-of-metrics-produced) | * | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `NETRUNTIME` | [OpenTelemetry.Instrumentation.Runtime](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.Runtime) | [Runtime metrics](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.Runtime-1.5.1/src/OpenTelemetry.Instrumentation.Process/README.md#metrics) | * | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `PROCESS` | [OpenTelemetry.Instrumentation.Process](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.Process) | [Process metrics](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.Process-0.5.0-beta.3/src/OpenTelemetry.Instrumentation.Process/README.md#metrics) | * | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | -| `NSERVICEBUS` | [NServiceBus](https://www.nuget.org/packages/NServiceBus) | [NServiceBus metrics](https://docs.particular.net/samples/open-telemetry/prometheus-grafana/#reporting-metric-values) | ≥8.0.0 | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `ASPNETCORE` | ASP.NET Core \[2\] **Not supported on .NET Framework** | [ASP.NET Core metrics](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.5.0/src/OpenTelemetry.Instrumentation.AspNetCore/README.md#list-of-metrics-produced) | * | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `HTTPCLIENT` | [System.Net.Http.HttpClient](https://docs.microsoft.com/dotnet/api/system.net.http.httpclient) and [System.Net.HttpWebRequest](https://docs.microsoft.com/dotnet/api/system.net.httpwebrequest) | [HttpClient metrics](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.5.0/src/OpenTelemetry.Instrumentation.Http/README.md#list-of-metrics-produced) | * | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `NETRUNTIME` | [OpenTelemetry.Instrumentation.Runtime](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.Runtime) | [Runtime metrics](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.Runtime-1.5.1/src/OpenTelemetry.Instrumentation.Process/README.md#metrics) | * | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `PROCESS` | [OpenTelemetry.Instrumentation.Process](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.Process) | [Process metrics](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.Process-0.5.0-beta.3/src/OpenTelemetry.Instrumentation.Process/README.md#metrics) | * | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | +| `NSERVICEBUS` | [NServiceBus](https://www.nuget.org/packages/NServiceBus) | [NServiceBus metrics](https://docs.particular.net/samples/open-telemetry/prometheus-grafana/#reporting-metric-values) | ≥8.0.0 | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) | \[1\]: The ASP.NET metrics are generated only if the `AspNet` trace instrumentation is also enabled. diff --git a/src/OpenTelemetry.AutoInstrumentation/Loading/Initializers/SqlClientInitializer.cs b/src/OpenTelemetry.AutoInstrumentation/Loading/Initializers/SqlClientInitializer.cs index 2c72905c1c..442fb6104b 100644 --- a/src/OpenTelemetry.AutoInstrumentation/Loading/Initializers/SqlClientInitializer.cs +++ b/src/OpenTelemetry.AutoInstrumentation/Loading/Initializers/SqlClientInitializer.cs @@ -27,6 +27,7 @@ internal class SqlClientInitializer public SqlClientInitializer(LazyInstrumentationLoader lazyInstrumentationLoader, PluginManager pluginManager) { _pluginManager = pluginManager; + lazyInstrumentationLoader.Add(new GenericInitializer("System.Data.SqlClient", InitializeOnFirstCall)); lazyInstrumentationLoader.Add(new GenericInitializer("Microsoft.Data.SqlClient", InitializeOnFirstCall)); #if NETFRAMEWORK diff --git a/test/Directory.Packages.props b/test/Directory.Packages.props index a63098c16b..4323d0c882 100644 --- a/test/Directory.Packages.props +++ b/test/Directory.Packages.props @@ -42,6 +42,7 @@ + diff --git a/test/IntegrationTests/LibraryVersions.g.cs b/test/IntegrationTests/LibraryVersions.g.cs index 16ef5ef04e..6074f4aa1d 100644 --- a/test/IntegrationTests/LibraryVersions.g.cs +++ b/test/IntegrationTests/LibraryVersions.g.cs @@ -76,7 +76,7 @@ public static class LibraryVersion new object[] { "8.1.1" }, #endif }; - public static readonly IReadOnlyCollection SqlClient = new List + public static readonly IReadOnlyCollection SqlClientMicrosoft = new List { #if DEFAULT_TEST_PACKAGE_VERSIONS new object[] { string.Empty } @@ -86,6 +86,14 @@ public static class LibraryVersion new object[] { "3.1.2" }, new object[] { "4.1.1" }, new object[] { "5.1.2" }, +#endif + }; + public static readonly IReadOnlyCollection SqlClientSystem = new List + { +#if DEFAULT_TEST_PACKAGE_VERSIONS + new object[] { string.Empty } +#else + new object[] { "4.8.5" }, #endif }; public static readonly IReadOnlyCollection MongoDB = new List diff --git a/test/IntegrationTests/SqlClientMicrosoftTests.cs b/test/IntegrationTests/SqlClientMicrosoftTests.cs index 72e24e6e56..cc0247a620 100644 --- a/test/IntegrationTests/SqlClientMicrosoftTests.cs +++ b/test/IntegrationTests/SqlClientMicrosoftTests.cs @@ -25,7 +25,7 @@ public class SqlClientMicrosoftTests : TestHelper private readonly SqlServerFixture _sqlServerFixture; public SqlClientMicrosoftTests(ITestOutputHelper output, SqlServerFixture sqlServerFixture) - : base("SqlClient", output) + : base("SqlClient.Microsoft", output) { _sqlServerFixture = sqlServerFixture; } @@ -34,9 +34,9 @@ public static IEnumerable GetData() { #if NETFRAMEWORK // 3.1.2 is not supported on .NET Framework. For details check: https://github.com/open-telemetry/opentelemetry-dotnet/issues/4243 - return LibraryVersion.SqlClient.Where(x => x.First().ToString() != "3.1.2"); + return LibraryVersion.SqlClientMicrosoft.Where(x => x.First().ToString() != "3.1.2"); #else - return LibraryVersion.SqlClient; + return LibraryVersion.SqlClientMicrosoft; #endif } diff --git a/test/IntegrationTests/SqlClientSystemDataTests.cs b/test/IntegrationTests/SqlClientSystemDataTests.cs index 876e5680d0..e8e5df2749 100644 --- a/test/IntegrationTests/SqlClientSystemDataTests.cs +++ b/test/IntegrationTests/SqlClientSystemDataTests.cs @@ -24,7 +24,7 @@ namespace IntegrationTests; public class SqlClientSystemDataTests : TestHelper { public SqlClientSystemDataTests(ITestOutputHelper output) - : base("SqlClient.NetFramework", output) + : base("SqlClient.System.NetFramework", output) { } diff --git a/test/IntegrationTests/SqlClientSystemTests.cs b/test/IntegrationTests/SqlClientSystemTests.cs new file mode 100644 index 0000000000..8d8e36c759 --- /dev/null +++ b/test/IntegrationTests/SqlClientSystemTests.cs @@ -0,0 +1,56 @@ +// +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using IntegrationTests.Helpers; +using Xunit.Abstractions; + +namespace IntegrationTests; + +[Collection(SqlServerCollection.Name)] +public class SqlClientSystemTests : TestHelper +{ + private readonly SqlServerFixture _sqlServerFixture; + + public SqlClientSystemTests(ITestOutputHelper output, SqlServerFixture sqlServerFixture) + : base("SqlClient.System", output) + { + _sqlServerFixture = sqlServerFixture; + } + + public static IEnumerable GetData() + { + return LibraryVersion.SqlClientSystem; + } + + [Theory] + [Trait("Category", "EndToEnd")] + [Trait("Containers", "Linux")] + [MemberData(nameof(GetData))] + public void SubmitTraces(string packageVersion) + { + using var collector = new MockSpansCollector(Output); + SetExporter(collector); + collector.Expect("OpenTelemetry.Instrumentation.SqlClient"); + + RunTestApplication(new() + { + Arguments = $"{_sqlServerFixture.Password} {_sqlServerFixture.Port}", + PackageVersion = packageVersion + }); + + collector.AssertExpectations(); + } +} diff --git a/test/test-applications/integrations/TestApplication.SqlClient/Program.cs b/test/test-applications/integrations/TestApplication.SqlClient.Microsoft/Program.cs similarity index 96% rename from test/test-applications/integrations/TestApplication.SqlClient/Program.cs rename to test/test-applications/integrations/TestApplication.SqlClient.Microsoft/Program.cs index dc0d0c1fba..07c5318e29 100644 --- a/test/test-applications/integrations/TestApplication.SqlClient/Program.cs +++ b/test/test-applications/integrations/TestApplication.SqlClient.Microsoft/Program.cs @@ -17,8 +17,11 @@ using Microsoft.Data.SqlClient; using TestApplication.Shared; -namespace TestApplication.SqlClient; +namespace TestApplication.SqlClient.Microsoft; +/// +/// This test application uses SqlConnection from Microsoft.Data.SqlClient (Nuget package). +/// public class Program { private const string CreateCommand = "CREATE TABLE MY_TABLE ( Id int, Value1 varchar(255), Value2 varchar(255) )"; diff --git a/test/test-applications/integrations/TestApplication.SqlClient/TestApplication.SqlClient.csproj b/test/test-applications/integrations/TestApplication.SqlClient.Microsoft/TestApplication.SqlClient.Microsoft.csproj similarity index 100% rename from test/test-applications/integrations/TestApplication.SqlClient/TestApplication.SqlClient.csproj rename to test/test-applications/integrations/TestApplication.SqlClient.Microsoft/TestApplication.SqlClient.Microsoft.csproj diff --git a/test/test-applications/integrations/TestApplication.SqlClient.NetFramework/Program.cs b/test/test-applications/integrations/TestApplication.SqlClient.System.NetFramework/Program.cs similarity index 96% rename from test/test-applications/integrations/TestApplication.SqlClient.NetFramework/Program.cs rename to test/test-applications/integrations/TestApplication.SqlClient.System.NetFramework/Program.cs index 7d813d3826..df5177cee3 100644 --- a/test/test-applications/integrations/TestApplication.SqlClient.NetFramework/Program.cs +++ b/test/test-applications/integrations/TestApplication.SqlClient.System.NetFramework/Program.cs @@ -17,8 +17,11 @@ using System.Data.SqlClient; using TestApplication.Shared; -namespace TestApplication.SqlClient; +namespace TestApplication.SqlClient.System; +/// +/// This test application uses SqlConnection from System.Data (shipped with .NET Framework). +/// public class Program { private const string CreateCommand = "CREATE TABLE MY_TABLE ( Id int, Value1 varchar(255), Value2 varchar(255) )"; diff --git a/test/test-applications/integrations/TestApplication.SqlClient.NetFramework/TestApplication.SqlClient.NetFramework.csproj b/test/test-applications/integrations/TestApplication.SqlClient.System.NetFramework/TestApplication.SqlClient.System.NetFramework.csproj similarity index 100% rename from test/test-applications/integrations/TestApplication.SqlClient.NetFramework/TestApplication.SqlClient.NetFramework.csproj rename to test/test-applications/integrations/TestApplication.SqlClient.System.NetFramework/TestApplication.SqlClient.System.NetFramework.csproj diff --git a/test/test-applications/integrations/TestApplication.SqlClient.System/Program.cs b/test/test-applications/integrations/TestApplication.SqlClient.System/Program.cs new file mode 100644 index 0000000000..995129887f --- /dev/null +++ b/test/test-applications/integrations/TestApplication.SqlClient.System/Program.cs @@ -0,0 +1,150 @@ +// +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System.Data.SqlClient; +using TestApplication.Shared; + +namespace TestApplication.SqlClient.System; + +/// +/// This test application uses SqlConnection from System.Data.SqlClient (NuGet package). +/// +public class Program +{ + private const string CreateCommand = "CREATE TABLE MY_TABLE ( Id int, Value1 varchar(255), Value2 varchar(255) )"; + private const string DropCommand = "DROP TABLE MY_TABLE"; + private const string InsertCommand = "INSERT INTO MY_TABLE VALUES ( 1, 'value1', 'value2' )"; + private const string SelectCommand = "SELECT * FROM MY_TABLE"; + + public static async Task Main(string[] args) + { + ConsoleHelper.WriteSplashScreen(args); + + (string databasePassword, string databasePort) = ParseArgs(args); + var connectionString = GetConnectionString(databasePassword, databasePort); + + using (var connection = new SqlConnection(connectionString)) + { + ExecuteCommands(connection); + } + + using (var connection = new SqlConnection(connectionString)) + { + await ExecuteAsyncCommands(connection); + } + } + + private static void ExecuteCommands(SqlConnection connection) + { + connection.Open(); + ExecuteCreate(connection); + ExecuteInsert(connection); + ExecuteSelect(connection); + ExecuteDrop(connection); + } + + private static void ExecuteCreate(SqlConnection connection) + { + ExecuteCommand(CreateCommand, connection); + } + + private static void ExecuteInsert(SqlConnection connection) + { + ExecuteCommand(InsertCommand, connection); + } + + private static void ExecuteSelect(SqlConnection connection) + { + ExecuteCommand(SelectCommand, connection); + } + + private static void ExecuteDrop(SqlConnection connection) + { + ExecuteCommand(DropCommand, connection); + } + + private static void ExecuteCommand(string commandString, SqlConnection connection) + { + try + { + using var command = new SqlCommand(commandString, connection); + using var reader = command.ExecuteReader(); + Console.WriteLine($"SQL query executed successfully: {commandString}"); + } + catch (Exception ex) + { + Console.WriteLine($"Error while executing SQL query: {commandString}.\n{ex.Message}"); + } + } + + private static async Task ExecuteAsyncCommands(SqlConnection connection) + { + await connection.OpenAsync(); + await ExecuteCreateAsync(connection); + await ExecuteInsertAsync(connection); + await ExecuteSelectAsync(connection); + await ExecuteDropAsync(connection); + } + + private static async Task ExecuteCommandAsync(string commandString, SqlConnection connection) + { + try + { + using var command = new SqlCommand(commandString, connection); + using var reader = await command.ExecuteReaderAsync(); + Console.WriteLine($"Async SQL query executed successfully: {commandString}"); + } + catch (Exception ex) + { + Console.WriteLine($"Error while executing async SQL query: {commandString}.\n{ex.Message}"); + } + } + + private static async Task ExecuteCreateAsync(SqlConnection connection) + { + await ExecuteCommandAsync(CreateCommand, connection); + } + + private static async Task ExecuteInsertAsync(SqlConnection connection) + { + await ExecuteCommandAsync(InsertCommand, connection); + } + + private static async Task ExecuteSelectAsync(SqlConnection connection) + { + await ExecuteCommandAsync(SelectCommand, connection); + } + + private static async Task ExecuteDropAsync(SqlConnection connection) + { + await ExecuteCommandAsync(DropCommand, connection); + } + + private static string GetConnectionString(string databasePassword, string databasePort) + { + return $"Server=127.0.0.1,{databasePort};User=sa;Password={databasePassword};TrustServerCertificate=True;"; + } + + private static (string DatabasePassword, string Port) ParseArgs(IReadOnlyList args) + { + if (args?.Count != 2) + { + throw new ArgumentException($"{nameof(TestApplication.SqlClient)}: requires two command-line arguments: "); + } + + return (DatabasePassword: args[0], Port: args[1]); + } +} diff --git a/test/test-applications/integrations/TestApplication.SqlClient.System/TestApplication.SqlClient.System.csproj b/test/test-applications/integrations/TestApplication.SqlClient.System/TestApplication.SqlClient.System.csproj new file mode 100644 index 0000000000..65a5808634 --- /dev/null +++ b/test/test-applications/integrations/TestApplication.SqlClient.System/TestApplication.SqlClient.System.csproj @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tools/LibraryVersionsGenerator/PackageVersionDefinitions.cs b/tools/LibraryVersionsGenerator/PackageVersionDefinitions.cs index bfdb877345..c5574e9f84 100644 --- a/tools/LibraryVersionsGenerator/PackageVersionDefinitions.cs +++ b/tools/LibraryVersionsGenerator/PackageVersionDefinitions.cs @@ -102,9 +102,9 @@ internal static class PackageVersionDefinitions }, new() { - IntegrationName = "SqlClient", + IntegrationName = "SqlClientMicrosoft", NugetPackageName = "Microsoft.Data.SqlClient", - TestApplicationName = "TestApplication.SqlClient", + TestApplicationName = "TestApplication.SqlClient.Microsoft", Versions = new List { new("1.1.4"), @@ -115,6 +115,17 @@ internal static class PackageVersionDefinitions } }, new() + { + IntegrationName = "SqlClientSystem", + NugetPackageName = "System.Data.SqlClient", + TestApplicationName = "TestApplication.SqlClient.System", + Versions = new List + { + new("4.8.5"), + new("*") + } + }, + new() { IntegrationName = "MongoDB", NugetPackageName = "MongoDB.Driver",