-
Notifications
You must be signed in to change notification settings - Fork 335
Add application identity to USERAGENT payload (V2) #4632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cheenamalhotra
wants to merge
12
commits into
main
Choose a base branch
from
dev/cheena/refactored-pancake
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
60037bc
Add SqlClient agent identifier to USERAGENT payload
cheenamalhotra c9f0cec
Address PR review feedback
cheenamalhotra 171d890
Make SqlClientAgent CLS-compliant and cover config failures
cheenamalhotra 1d296c9
Lock SqlClientAgent underlying type and drop stale attribute
cheenamalhotra 0c2bfcc
Inline the agent registration sample
cheenamalhotra a1ae554
Tests | Stop CancelAndDisposePreparedCommand deadlocking on the catalog
cheenamalhotra 9c7f4b0
Report agent registration outcome and stop using the catalog in cance…
cheenamalhotra 2f82e5e
Report application identity in USERAGENT payload V2
cheenamalhotra 1510d6f
Preserve application identity across clones, add sqlpackage
cheenamalhotra d849cf4
Reject identity changes after login, propagate to discovery login
cheenamalhotra 095d84e
Document identity exception and trust boundary
cheenamalhotra e8a5509
Leave localized resx files to the OneLocBuild pipeline
cheenamalhotra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| <docs> | ||
| <members name="SqlClientApp"> | ||
| <SqlClientApp> | ||
| <summary> | ||
| Specifies the known application identifiers that Microsoft.Data.SqlClient reports for user agent telemetry. | ||
| </summary> | ||
| <remarks> | ||
| <para> | ||
| Production applications that meet the bar are welcome to reserve an identifier here. | ||
| </para> | ||
| <para> | ||
| Identifier reservations are as follows: | ||
| </para> | ||
| <list type="bullet"> | ||
| <item> | ||
| <description>0x0001-0x7FFF: Microsoft-defined large-scale applications.</description> | ||
| </item> | ||
| <item> | ||
| <description>0x8000-0xBFFF: Reserved for small-scale use.</description> | ||
| </item> | ||
| <item> | ||
| <description>0xC000-0xFFFF: Public and developer use.</description> | ||
| </item> | ||
| </list> | ||
| <para> | ||
| An unregistered identifier may still be reported by casting a value to this type. Identifiers are limited to | ||
| the 16-bit space the protocol allows, so a value outside 0x0000 to 0xFFFF is rejected when it is assigned to | ||
| <see cref="P:Microsoft.Data.SqlClient.SqlConnection.SqlClientAppId" />. | ||
| </para> | ||
| </remarks> | ||
| </SqlClientApp> | ||
| <Unknown> | ||
| <summary> | ||
| No application identity is reported. This is the default. | ||
| </summary> | ||
| <value> | ||
| 0 | ||
| </value> | ||
| </Unknown> | ||
| <EntityFramework> | ||
| <summary> | ||
| The Microsoft Entity Framework Core SQL Server provider. | ||
| </summary> | ||
| <value> | ||
| 1 | ||
| </value> | ||
| </EntityFramework> | ||
| <SemanticKernel> | ||
| <summary> | ||
| Microsoft Semantic Kernel. | ||
| </summary> | ||
| <value> | ||
| 2 | ||
| </value> | ||
| </SemanticKernel> | ||
| <ManagementStudio> | ||
| <summary> | ||
| Microsoft SQL Server Management Studio. | ||
| </summary> | ||
| <value> | ||
| 3 | ||
| </value> | ||
| </ManagementStudio> | ||
| <SqlManagementObjects> | ||
| <summary> | ||
| Microsoft SQL Server Management Objects. | ||
| </summary> | ||
| <value> | ||
| 4 | ||
| </value> | ||
| </SqlManagementObjects> | ||
| <DataTierApplicationFramework> | ||
| <summary> | ||
| Microsoft SQL Server Data-Tier Application Framework. | ||
| </summary> | ||
| <value> | ||
| 5 | ||
| </value> | ||
| </DataTierApplicationFramework> | ||
| <SqlToolsService> | ||
| <summary> | ||
| Microsoft SQL Tools Service. | ||
| </summary> | ||
| <value> | ||
| 6 | ||
| </value> | ||
| </SqlToolsService> | ||
| <AspNetCoreDistributedSqlServerCache> | ||
| <summary> | ||
| Microsoft ASP.NET Core distributed SQL Server cache. | ||
| </summary> | ||
| <value> | ||
| 7 | ||
| </value> | ||
| </AspNetCoreDistributedSqlServerCache> | ||
| <EntityFramework6> | ||
| <summary> | ||
| Microsoft Entity Framework 6 SQL Server provider. | ||
| </summary> | ||
| <value> | ||
| 8 | ||
| </value> | ||
| </EntityFramework6> | ||
| <AzureFunctionsSqlExtension> | ||
| <summary> | ||
| Microsoft Azure Functions SQL extension. | ||
| </summary> | ||
| <value> | ||
| 9 | ||
| </value> | ||
| </AzureFunctionsSqlExtension> | ||
| <OrleansAdoNet> | ||
| <summary> | ||
| Microsoft Orleans ADO.NET providers. | ||
| </summary> | ||
| <value> | ||
| 10 | ||
| </value> | ||
| </OrleansAdoNet> | ||
| <DurableTaskSqlServer> | ||
| <summary> | ||
| Microsoft Durable Task SQL Server provider. | ||
| </summary> | ||
| <value> | ||
| 11 | ||
| </value> | ||
| </DurableTaskSqlServer> | ||
| <SqlPackage> | ||
| <summary> | ||
| The <c>sqlpackage</c> command-line tool. | ||
| </summary> | ||
| <value> | ||
| 12 | ||
| </value> | ||
| <remarks> | ||
| <c>sqlpackage</c> is built on the Data-Tier Application Framework, but reports its own identifier so that | ||
| command-line use can be told apart from other callers of that framework. | ||
| </remarks> | ||
| </SqlPackage> | ||
| </members> | ||
| </docs> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientApp.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace Microsoft.Data.SqlClient; | ||
|
|
||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlClientApp.xml' path='docs/members[@name="SqlClientApp"]/SqlClientApp/*' /> | ||
| public enum SqlClientApp | ||
| { | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlClientApp.xml' path='docs/members[@name="SqlClientApp"]/Unknown/*' /> | ||
| Unknown = 0x0000, | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlClientApp.xml' path='docs/members[@name="SqlClientApp"]/EntityFramework/*' /> | ||
| EntityFramework = 0x0001, | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlClientApp.xml' path='docs/members[@name="SqlClientApp"]/SemanticKernel/*' /> | ||
| SemanticKernel = 0x0002, | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlClientApp.xml' path='docs/members[@name="SqlClientApp"]/ManagementStudio/*' /> | ||
| ManagementStudio = 0x0003, | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlClientApp.xml' path='docs/members[@name="SqlClientApp"]/SqlManagementObjects/*' /> | ||
| SqlManagementObjects = 0x0004, | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlClientApp.xml' path='docs/members[@name="SqlClientApp"]/DataTierApplicationFramework/*' /> | ||
| DataTierApplicationFramework = 0x0005, | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlClientApp.xml' path='docs/members[@name="SqlClientApp"]/SqlToolsService/*' /> | ||
| SqlToolsService = 0x0006, | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlClientApp.xml' path='docs/members[@name="SqlClientApp"]/AspNetCoreDistributedSqlServerCache/*' /> | ||
| AspNetCoreDistributedSqlServerCache = 0x0007, | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlClientApp.xml' path='docs/members[@name="SqlClientApp"]/EntityFramework6/*' /> | ||
| EntityFramework6 = 0x0008, | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlClientApp.xml' path='docs/members[@name="SqlClientApp"]/AzureFunctionsSqlExtension/*' /> | ||
| AzureFunctionsSqlExtension = 0x0009, | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlClientApp.xml' path='docs/members[@name="SqlClientApp"]/OrleansAdoNet/*' /> | ||
| OrleansAdoNet = 0x000A, | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlClientApp.xml' path='docs/members[@name="SqlClientApp"]/DurableTaskSqlServer/*' /> | ||
| DurableTaskSqlServer = 0x000B, | ||
| /// <include file='../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlClientApp.xml' path='docs/members[@name="SqlClientApp"]/SqlPackage/*' /> | ||
| SqlPackage = 0x000C | ||
| } | ||
75 changes: 75 additions & 0 deletions
75
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientDriverProperties.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace Microsoft.Data.SqlClient; | ||
|
|
||
| /// <summary> | ||
| /// Driver-owned feature flags reported in the Driver Properties part of the | ||
| /// USERAGENT login feature extension payload. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// This part is driver-owned, so its meaning is defined entirely by | ||
| /// Microsoft.Data.SqlClient and carries no cross-driver contract. Other | ||
| /// drivers use the same part for their own purposes. | ||
| /// </remarks> | ||
| [Flags] | ||
| internal enum SqlClientDriverProperties : ushort | ||
| { | ||
| /// <summary>No tracked features are enabled.</summary> | ||
| None = 0x0000, | ||
|
|
||
| /// <summary> | ||
| /// The connection pool V2 implementation | ||
| /// (<c>Switch.Microsoft.Data.SqlClient.UseConnectionPoolV2</c>) is | ||
| /// enabled. | ||
| /// </summary> | ||
| ConnectionPoolV2 = 0x0001 | ||
|
cheenamalhotra marked this conversation as resolved.
|
||
| } | ||
|
|
||
| /// <summary> | ||
| /// Resolves the <see cref="SqlClientDriverProperties"/> flags that describe | ||
| /// how this process is configured. | ||
| /// </summary> | ||
| internal static class SqlClientDriverPropertiesResolver | ||
| { | ||
| /// <summary> | ||
| /// The flags describing the current process. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// The flags are sourced from process-wide switches, so this is stable | ||
| /// for the life of the process. | ||
| /// </remarks> | ||
| internal static SqlClientDriverProperties Current => | ||
| Resolve(LocalAppContextSwitches.UseConnectionPoolV2); | ||
|
|
||
| /// <summary> | ||
| /// Maps the process configuration to the flags that describe it. | ||
| /// </summary> | ||
| /// <param name="useConnectionPoolV2"> | ||
| /// Whether the connection pool V2 implementation is enabled. | ||
| /// </param> | ||
| /// <returns> | ||
| /// The flags describing the supplied configuration. | ||
| /// </returns> | ||
| /// <remarks> | ||
| /// The mapping is kept separate from <see cref="Current"/> because the | ||
| /// switches it reads are cached for the life of the process, which makes | ||
| /// them impractical to vary in a test. | ||
| /// </remarks> | ||
| internal static SqlClientDriverProperties Resolve(bool useConnectionPoolV2) | ||
| { | ||
| SqlClientDriverProperties properties = SqlClientDriverProperties.None; | ||
|
|
||
| if (useConnectionPoolV2) | ||
| { | ||
| properties |= SqlClientDriverProperties.ConnectionPoolV2; | ||
| } | ||
|
|
||
| return properties; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.