Repository navigation
[7.0 Backport] Report configured async compatibility switches using user agent v2 - #4913
Conversation
Adapt PR #4911 to the release/7.0 v1 payload: emit the v2 App Id field as zero and report the driver flags without adding application identity public APIs. Include legacy build references, configured-value coverage, sync/async login coverage, and the Windows managed-networking cache restoration test.
There was a problem hiding this comment.
🔵 Needs a closer look
The servicing-branch wire-format upgrade needs human confirmation because non-Windows execution and downstream telemetry decoding remain unverified.
No open issues 🎉
What changed in this PR
Backports configured async-compatibility telemetry to SqlClient 7.0 by upgrading USERAGENT from v1 to v2. This enables usage measurement before async defaults change, without changing parser behavior or public APIs.
Changes:
- Adds the nine-field v2 payload with App Id fixed at
0and flags for pool V2 and configured async compatibility switches. - Introduces a shared flag resolver and includes it in both active legacy build projects.
- Expands tests for flag combinations, serialization limits, switch defaults and restoration, and synchronous/asynchronous login.
| File | Description |
|---|---|
| src/Microsoft.Data.SqlClient/tests/UnitTests/UserAgentTests.cs | Verifies v2 fields, hexadecimal flags, and truncation. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/SqlClientDriverPropertiesTests.cs | Tests flag combinations, underlying type, and current values. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionTests.cs | Checks v2 payloads during sync/async login, with and without acknowledgement. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/LocalAppContextSwitchesTest.cs | Tests configured versus effective values, defaults, and cache restoration. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/UserAgent.cs | Builds and documents the v2 telemetry payload. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientDriverProperties.cs | Defines telemetry flags and their shared resolver. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs | Exposes configured async compatibility independently of the parser override. |
| src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj | Includes the resolver in the .NET Framework build. |
| src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj | Includes the resolver in the legacy .NET build. |
Review effort: Balanced
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/7.0 #4913 +/- ##
===============================================
- Coverage 73.09% 66.26% -6.83%
===============================================
Files 280 276 -4
Lines 43419 66327 +22908
===============================================
+ Hits 31738 43953 +12215
- Misses 11681 22374 +10693
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Adapt #4911 for
release/7.0so configured async compatibility usage can be measured before changing async defaults. Related 7.1 backport: #4912. The source PR is currently open.Unlike main and 7.1, 7.0 emits the seven-field USERAGENT v1 payload and has no Driver Properties field. Upgrade the telemetry payload to the nine-field v2 layout:
App Id remains fixed at
0; this does not add the RegisteredApplication public API. Driver Properties uses the same assignments as main and 7.1:0x1: connection pool V2 enabled.0x2: configuredSwitch.Microsoft.Data.SqlClient.UseCompatibilityAsyncBehaviouris true.0x4: configuredSwitch.Microsoft.Data.SqlClient.UseCompatibilityProcessSniis true.The compatibility bits are independent of the parser's effective override. For example, with pool V2 disabled, async=false and ProcessSni=true reports
4, while unset compatibility switches retain their true defaults and report6. Parser behavior and public APIs remain unchanged. Telemetry consumers should decode these fields and bits only for versions containing the instrumentation.Add the shared resolver source to the active legacy .NET and .NET Framework projects. Include the managed-networking cache restoration test through reflection under 7.0's existing
NET && _WINDOWSguard; this branch only defines that cache and helper property in its Windows build. XML documentation describes the v2 payload and bit assignments.Testing
Focused user agent, driver properties, AppContext switch, LOGIN7 payload, and simulated-server tests passed on Windows:
Coverage includes all eight driver flag combinations, configured versus effective async compatibility, default switch values, hexadecimal serialization, payload truncation and maximum field lengths, and sync/async login with and without a server acknowledgement. New tests follow Arrange / Act / Assert.
dotnet build build.proj "-t:BuildNetFx;BuildNetCore" -p:ReferenceType=Project -p:Configuration=Debugpassed with zero warnings and errors, verifying both active legacy build surfaces.git diff --checkpassed.Non-Windows execution and server-side telemetry ingestion/downstream decoding were not exercised locally.
Guidelines
Suggested release note: Updated user agent telemetry to v2 and added driver-property bits reporting connection pool V2 and configured async compatibility switches.