Skip to content

Merge | Enable SqlClientDiagnosticListener on .NET Framework #3493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

edwardneal
Copy link
Contributor

Description

This continues work on the SqlConnection merge, tackling one of a few functional differences between netcore and netfx. The SqlClientDiagnosticListener and its associated strongly-typed objects make up a very large API surface, and this PR ports them all over. It also makes the necessary changes to SqlConnection and SqlTransaction (but not SqlCommand) to send the associated events.

I've limited the scope here to SqlConnection and SqlTransaction to stay out of the way of #3473 and its successors. I can wait for #3473 to be merged and turn this into a single clean PR which enables SqlClientDiagnosticListener everywhere. If that's likely to slow down your work as you work through the SqlCommand merge @benrr101 then we can review this PR as-is.

By implication, I've added a dependency from the netfx SqlClient on System.Diagnostics.DiagnosticSource 8.0.1.

Issues

Contributes to #1261. Avoids touching SqlCommand to avoid merge conflicts with #3473. Loosely relates to #2210.

Testing

Existing tests suffice; I've enabled test coverage for the newly-added methods, and this coverage passes.

@benrr101
Copy link
Contributor

I was kinda wondering how hard it would be to add diagnostics to netfx while messing around with the differences in sqlcommand. It'd definitely ease up the differences. I thiiiink the best way to sequence these changes would be to, as you suggested, leave SqlCommand alone until we get it merged (will take a while, i'm trying a new strategy this time). The merged SqlCommand will have all the diagnostics code wrapped in #if NET, so we can just remove them when it's all ready.

But I'd also like to get @David-Engel's feedback on this before you get too deep.

@benrr101 benrr101 added Public API 🆕 Issues/PRs that introduce new APIs to the driver. P2 Use to label moderate priority issue - impacts atleast more than 1 customer. labels Jul 21, 2025
@benrr101 benrr101 added this to the 7.0-preview1 milestone Jul 21, 2025
@paulmedynski
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link

codecov bot commented Jul 22, 2025

Codecov Report

❌ Patch coverage is 82.81250% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.05%. Comparing base (9744a8e) to head (d41b6ed).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...etfx/src/Microsoft/Data/SqlClient/SqlConnection.cs 81.66% 11 Missing ⚠️

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

HEAD has 1 upload less than BASE
Flag BASE (9744a8e) HEAD (d41b6ed)
addons 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3493      +/-   ##
==========================================
- Coverage   67.81%   59.05%   -8.76%     
==========================================
  Files         276      270       -6     
  Lines       62417    62146     -271     
==========================================
- Hits        42329    36703    -5626     
- Misses      20088    25443    +5355     
Flag Coverage Δ
addons ?
netcore 61.70% <100.00%> (-11.20%) ⬇️
netfx 61.94% <82.25%> (-4.68%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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.

@cheenamalhotra
Copy link
Member

I think this is great to have, given that .NET Framework support is now available through the provided package.

We have learned that products generally benefit from these diagnostics, so I am in full support of porting this over to NetFx!

@edwardneal
Copy link
Contributor Author

Thanks all. I'll pull this out of draft for review, and we'll just make sure that the telemetry in SqlCommand is fully merged by the time v7.0 is released. There are only about 100 lines of changes there, so it should be reasonably simple.

@edwardneal edwardneal marked this pull request as ready for review July 24, 2025 20:40
@edwardneal edwardneal requested a review from a team as a code owner July 24, 2025 20:40
@benrr101
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Use to label moderate priority issue - impacts atleast more than 1 customer. Public API 🆕 Issues/PRs that introduce new APIs to the driver.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants