Skip to content

[7.0 Backport] Report configured async compatibility switches using user agent v2 - #4913

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

benrr101 merged 1 commit into
release/7.0from
dev/russellben/useragent-70

Conversation

@benrr101

Copy link
Copy Markdown
Contributor

Description

Adapt #4911 for release/7.0 so 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:

2|MS-MDS|{Driver Version}|{Arch}|{OS Type}|{OS Info}|{Runtime Info}|0|{Driver Properties}

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: configured Switch.Microsoft.Data.SqlClient.UseCompatibilityAsyncBehaviour is true.
  • 0x4: configured Switch.Microsoft.Data.SqlClient.UseCompatibilityProcessSni is 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 report 6. 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 && _WINDOWS guard; 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:

  • .NET Framework 4.6.2: 67 passed.
  • .NET 8: 68 passed.
  • .NET 9: 68 passed.
  • .NET 10: 68 passed.

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=Debug passed with zero warnings and errors, verifying both active legacy build surfaces. git diff --check passed.

Non-Windows execution and server-side telemetry ingestion/downstream decoding were not exercised locally.

Guidelines

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

Suggested release note: Updated user agent telemetry to v2 and added driver-property bits reporting connection pool V2 and configured async compatibility switches.

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.
@benrr101
benrr101 requested review from a team and a balanced review from Copilot October 23, 2026 18:33
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board 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

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 0 and 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

@benrr101 benrr101 added this to the 7.0.4 milestone Oct 23, 2026
@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.54839% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.26%. Comparing base (bfb4ba5) to head (ff99f4c).
⚠️ Report is 3 commits behind head on release/7.0.

Files with missing lines Patch % Lines
...qlClient/src/Microsoft/Data/SqlClient/UserAgent.cs 66.66% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (bfb4ba5) and HEAD (ff99f4c). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (bfb4ba5) HEAD (ff99f4c)
CI-SqlClient 1 0
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     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 66.26% <93.54%> (?)

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 5ba8dfb into release/7.0 Oct 26, 2026
286 of 287 checks passed
@benrr101
benrr101 deleted the dev/russellben/useragent-70 branch October 26, 2026 20:18
@github-project-automation github-project-automation Bot moved this from To triage to Done in SqlClient Board Oct 26, 2026
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