Skip to content

Expose SqlBatch commands on the command diagnostic payloads - #4577

Draft
PetarJerinic wants to merge 2 commits into
dotnet:mainfrom
PetarJerinic:issue-4545
Draft

Expose SqlBatch commands on the command diagnostic payloads#4577
PetarJerinic wants to merge 2 commits into
dotnet:mainfrom
PetarJerinic:issue-4545

Conversation

@PetarJerinic

@PetarJerinic PetarJerinic commented Aug 22, 2026

Copy link
Copy Markdown

Description

SqlClientCommandBefore, SqlClientCommandAfter, and SqlClientCommandError are extended to contain BatchCommands. It holds batch commands of SqlBatch.

The shape follows what was specified within #4545.
API Changes are additive, and are present in src/Microsoft.Data.SqlClient/ref/Microsoft.Data.SqlClient.Diagnostics.cs and the doc/snippets/.../SqlClientDiagnostic.xml

Issues

Fixes #4545

Testing

Three new test files:

  • SqlClientCommandPayloadTest.cs - 9 cases validating three payload types directly
  • SqlDiagnosticListenerTest.cs - 1 case confirming WriteCommandAfter passes sqlCommand.BatchCommands through
  • BatchDiagnosticsTests.cs - 9 e2e cases with DiagnosticListener subscriber

Note: WriteCommandAfter on a successful batch was not covered. Simulated TDS server cannot answer an RPC. It could be added to ManualTests/TracingTests/DiagnosticTest with [Trait("Category", "flaky")], but left it out to avoid adding coverage that can't gate. Happy to add it if it's preferred as a documentation value.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@PetarJerinic

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

@PetarJerinic

Copy link
Copy Markdown
Author

@cheenamalhotra this PR implements the shape in #4545. Could someone run the pipelines?

@cheenamalhotra

Copy link
Copy Markdown
Member

/azp run

@cheenamalhotra cheenamalhotra added this to the 8.0.0-preview1 milestone Aug 24, 2026
@cheenamalhotra cheenamalhotra added the Public API 🆕 Issues/PRs that introduce new APIs to the driver. label Aug 24, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@PetarJerinic

Copy link
Copy Markdown
Author

@cheenamalhotra I fixed the subscription leak in BatchDiagnosticsTests.cs that caused some of the existing tests to fail. Can we do a fresh /azp run?

@cheenamalhotra

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Public API 🆕 Issues/PRs that introduce new APIs to the driver.

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

Feature | Surface batch information on the SqlClient diagnostic events

2 participants