Skip to content

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 86.88525% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.54%. Comparing base (cf2bdc7) to head (e563323).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...etfx/src/Microsoft/Data/SqlClient/SqlConnection.cs 85.96% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3493      +/-   ##
==========================================
- Coverage   63.19%   60.54%   -2.66%     
==========================================
  Files         274      269       -5     
  Lines       62478    61247    -1231     
==========================================
- Hits        39486    37083    -2403     
- Misses      22992    24164    +1172     
Flag Coverage Δ
addons ?
netcore 63.47% <100.00%> (-3.30%) ⬇️
netfx 62.22% <86.44%> (-3.95%) ⬇️

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).

@David-Engel
Copy link
Contributor

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

Looking back, it seems we didn't add it to netfx initially because the underlying support wasn't there. Now it's there via the extension package. Seems like a no brainer to extend SqlClientDiagnosticListener to NetFx now.

benrr101
benrr101 previously approved these changes Jul 30, 2025
Copy link
Contributor

@benrr101 benrr101 left a comment

Choose a reason for hiding this comment

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

Overall looks pretty good to me! Thank you for recognizing we can bring in this functionality for netfx and putting in the effort to do it!

@paulmedynski
Copy link
Contributor

@edwardneal - Can you resolve conflicts here? I'll do a review once that's done.

@edwardneal
Copy link
Contributor Author

Thanks @paulmedynski, I've just completed the merge.

@paulmedynski
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.

5 participants