Repository navigation
[7.1 Backport] Report configured async compatibility switches in user agent telemetry - #4912
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
No actionable defects were identified, but current-head CI, outstanding PR feedback, trusted policy references, and non-Windows validation remain unverified.
No open issues 🎉
What changed in this PR
Backports #4911 to release/7.1, adding telemetry for configured async compatibility switches without changing parser behavior, public APIs, or the user agent payload format.
Changes:
- Adds independent Driver Properties bits for async compatibility (
0x2) and ProcessSni compatibility (0x4), preserving the pool V2 bit. - Tests all eight flag combinations, defaults, effective compatibility behavior, and serialization.
- Guards the managed-networking test helper’s cache setter on Windows and adds restoration coverage.
| File | Description |
|---|---|
| src/Microsoft.Data.SqlClient/tests/UnitTests/UserAgentTests.cs | Tests serialization of all flag combinations. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/RegisteredApplicationTests.cs | Updates resolver assertions for the new flags. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/LocalAppContextSwitchesTest.cs | Tests defaults, independent flags, overrides, and cache restoration. |
| src/Microsoft.Data.SqlClient/tests/Common/LocalAppContextSwitchesHelper.cs | Restricts managed-networking cache writes to Windows and corrects comments. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/UserAgent.cs | Documents the new telemetry bits. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientDriverProperties.cs | Defines and resolves the compatibility flags. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs | Exposes configured async compatibility before the effective override. |
Review effort: Balanced
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/7.1 #4912 +/- ##
===============================================
- Coverage 66.52% 65.22% -1.30%
===============================================
Files 291 285 -6
Lines 45101 68073 +22972
===============================================
+ Hits 30002 44401 +14399
- Misses 15099 23672 +8573
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
Backport #4911 to
release/7.1to collect configured async compatibility usage before changing async defaults. Add two bits to the existing user agent v2 Driver Properties mask:0x2:Switch.Microsoft.Data.SqlClient.UseCompatibilityAsyncBehaviouris configured true.0x4:Switch.Microsoft.Data.SqlClient.UseCompatibilityProcessSniis configured true.Report both values independently, before the ProcessSni override. With pool V2 disabled, async=false and ProcessSni=true reports
4; unset compatibility switches retain their true defaults and report6. Existing parser behavior, public APIs, payload format, and the pool V2 bit remain unchanged. XML documentation describes the new bits. Telemetry consumers should decode these bits only for versions containing the instrumentation.The source PR is currently open. This backport also includes the managed-networking cache restoration test, adapted to 7.1's private cache via reflection, and the test helper's Windows-only setter guard. The guard preserves the unused cache on non-Windows platforms.
Testing
Focused telemetry, registered application, AppContext switch, login-payload, and simulated-server tests passed:
Tests follow Arrange / Act / Assert and cover all eight combinations of the compatibility flags and pool V2, default values, the parser's effective compatibility override, serialized payloads, and managed-networking cache restoration. Validation ran on Windows; non-Windows execution and server-side telemetry ingestion were not exercised locally.
git diff --checkpassed.Guidelines
Suggested release note: Added user agent telemetry bits reporting the configured async and ProcessSni compatibility switches.
Full Disclosure: This was fully implemented by 🤖