Skip to content

[7.1 Backport] Report configured async compatibility switches in user agent telemetry - #4912

Merged
benrr101 merged 1 commit into
release/7.1from
dev/russellben/useragent-71
Oct 26, 2026
Merged

benrr101 merged 1 commit into
release/7.1from
dev/russellben/useragent-71

Conversation

@benrr101

@benrr101 benrr101 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Backport #4911 to release/7.1 to 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.UseCompatibilityAsyncBehaviour is configured true.
  • 0x4: Switch.Microsoft.Data.SqlClient.UseCompatibilityProcessSni is 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 report 6. 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:

  • .NET Framework 4.6.2: 94 passed.
  • .NET 8: 96 passed.
  • .NET 9: 96 passed.
  • .NET 10: 96 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 --check passed.

Guidelines

  • Tests added or updated.
  • Public API changes documented (no public API changes).

Suggested release note: Added user agent telemetry bits reporting the configured async and ProcessSni compatibility switches.

Full Disclosure: This was fully implemented by 🤖

Backport 34b767e (PR #4911). Include the managed-networking cache restoration test, adapted to the private 7.1 cache through reflection, and guard the test helper setter on non-Windows platforms.
@benrr101
benrr101 requested review from a team and a balanced review from Copilot October 23, 2026 18:24
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Oct 23, 2026
@benrr101 benrr101 added this to the 7.1.2 milestone Oct 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.22%. Comparing base (ab3d40a) to head (df3cbf0).
⚠️ Report is 8 commits behind head on release/7.1.

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     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 65.22% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@benrr101
benrr101 merged commit bc55c13 into release/7.1 Oct 26, 2026
207 of 208 checks passed
@benrr101
benrr101 deleted the dev/russellben/useragent-71 branch October 26, 2026 15:06
@github-project-automation github-project-automation Bot moved this from To triage to Done in SqlClient Board Oct 26, 2026
Copilot AI mentioned this pull request Nov 24, 2026
3 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants