8000 Merge | Merge metrics/performance counter methodology by edwardneal · Pull Request #3251 · dotnet/SqlClient · GitHub
[go: up one dir, main page]

Skip to content

Merge | Merge metrics/performance counter methodology #3251

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

Merged
merged 8 commits into from
Apr 21, 2025

Conversation

edwardneal
Copy link
Contributor

Relates to #1261, but also lays the groundwork for #2211.

SqlClientcurrently has two different ways to record metrics - .NET Core has counters on the EventSource, and .NET Framework has performance counters. These are usually recorded at the same time, but they're separated by various #if NET conditional compilation blocks.

This PR consolidates both metric surfaces into a single SqlClientMetrics class, with various HardConnectRequest methods which increment a performance counter or event counter. This means that we've no longer got this type of conditional compilation scattered throughout the connection logic.

@benrr101 - this is the outcome of the conversation we had while merging DbConnectionInternal. I've split it out so it's easier to review.

I'd appreciate a CI run please.

Move functionality into a new Microsoft.Data.SqlClient.Diagnostics.SqlClientMetrics type. This common interface encapsulates both event counters and performance counters.
@David-Engel
Copy link
Contributor

/azp run

Copy link
Azure Pipelines successfully started running 1 pipeline(s).

@paulmedynski paulmedynski added this to the 6.1-preview1 milestone Apr 2, 2025
@cheenamalhotra
Copy link
Member

/azp run

Copy link
Azure Pipelines successfully started running 1 pipeline(s).

@mdaigle mdaigle self-assigned this Apr 2, 2025
Copy link
codecov bot commented Apr 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (c5e3c40) to head (1a82a49).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #3251       +/-   ##
==========================================
- Coverage   72.98%       0   -72.99%     
==========================================
  Files         299       0      -299     
  Lines       57215       0    -57215     
==========================================
- Hits        41760       0    -41760     
+ Misses      15455       0    -15455     
Flag Coverage Δ
addons ?
netcore ?
netfx ?

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.

Copy link
Contributor
@mdaigle mdaigle 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 good, but I don't know enough about the test coverage of this functionality to approve just based on a successful CI run. Have you done any manual validation that the events and metrics are still emitted as expected?

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, love it! 🚀 🚀 🚀
I'd love it more if we can get it all into a single file, but I'll leave that to your judgement.

@paulmedynski
Copy link
Contributor

/azp run

@paulmedynski paulmedynski self-assigned this Apr 8, 2025
Copy link
Azure Pipelines successfully started running 1 pipeline(s).

@benrr101 benrr101 added the Common Project 🚮 Things that relate to the common project project label Apr 8, 2025
@benrr101
Copy link
Contributor
benrr101 commented Apr 8, 2025

/azp run

Copy link
Azure Pipelines successfully started running 1 pipeline(s).

@benrr101
Copy link
Contributor
benrr101 commented Apr 9, 2025

@edwardneal ok, so looking at these failures, I thiiiink I understand why these failures are happening. Sorta. The MetricsTest file is only pulled into the test project if it's on test set 3 (or no test set), that's why only some of the test jobs are failing (specifically the ones that end with 3). That test file has references to the event source class, which is internal. Since we don't have internalsvisibleto the test projects (yet ... @mdaigle did you give up on that?), I don't think we can access that class from the test project.

The part I don't get tho, if I build it in the IDE, it doesn't complain at all. But that build specifies no test set, which makes me wonder if something including a file or property that makes it all work. Nothing stood out at me, but I didn't go through it with a fine toothed comb.

@mdaigle
Copy link
Contributor
mdaigle commented Apr 10, 2025

@benrr101 I'm going to revert the change I made to allow internalsVisibleTo because, like you saw, it works in the IDE, but not in MSBuild, which is confusing. MSBuild compiles using the reference assemblies which don't currently contain any of the internal types. Visual studio (and I'm assuming Rider, too) compiles using the implementation assemblies, which do contain the internal types.

#3268

@benrr101
Copy link
Contributor

@edwardneal Update - apparently something is really messed up with how we have our projects set up.... As per @mdaigle, the ref projects are being used for the internalsvisibleto when building from command line, but the implementation projects are being used when building from IDE. Thus, we see the failures of your unit tests when we build the project during CI. I don't think we have a good plan for fixing this anytime soon (it's sort of predicated on a lot of other things being fixed). But in the meantime, Malcolm is going to back out the internalsvisibleto change so people don't get the wrong idea that they can use internal classes in test projects safely.

To address this ... I don't know what's best. I'd like to keep the tests in the codebase so we can use them someday, but maybe just comment them out? (it grosses me out to even type that)

@edwardneal
Copy link
Contributor Author

Good catch, thanks - I'd not yet seen the test results. It's worth keeping in mind that this test originally used reflection; I'll swap it back to doing so, and we can avoid the problem completely.

@edwardneal
Copy link
Contributor Author

I've adjusted MetricsTest to use reflection again - could I have another CI run please?

@benrr101
Copy link
Contributor

/azp run

Copy link
Azure Pipelines successfully started running 1 pipeline(s).

@benrr101
Copy link
Contributor
benrr101 commented Apr 16, 2025

@edwardneal please don't mind that I just went ahead and fixed the merge conflict for you :)

@benrr101
Copy link
Contributor

/azp run

Copy link
Azure Pipelines successfully started running 1 pipeline(s).

@mdaigle mdaigle merged commit 042ea74 into dotnet:main Apr 21, 2025
122 checks passed
@edwardneal edwardneal deleted the merge/metrics branch April 21, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Common Project 🚮 Things that relate to the common project project
Projects
None yet
Development

Succe 3F4A ssfully merging this pull request may close these issues.

6 participants
0