-
Notifications
You must be signed in to change notification settings - Fork 286
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
Supporting Event counter in .Net core #719
Conversation
# Conflicts: # src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs # src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs # src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add test cases to validate counters that provide maximum possible code coverage.
src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
Outdated
Show resolved
Hide resolved
When trying to use pre-processor definitions to include functionality it's hard to make sure that you include code only where it is supported and make sure it is included in later builds using definitions that don't exist yet. For example using Annoying as it is, the best way to avoid this is to is to use exclusions. so something like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the below implementation comment, the de-facto standard seems to be to just use the package name/namespace - so I'd use Microsoft.Data.SqlClient (and omit the trailing .EventSource)
...osoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientEventSource.NetCoreApp.cs
Outdated
Show resolved
Hide resolved
Great point @Wraith2, Our approach is to keep update the directive definitions in the
|
This would be a good idea. The only concern is this is a breaking change. |
b3eb777
to
51a6f63
Compare
51a6f63
to
0df6a55
Compare
2ef8648
to
74bb4da
Compare
d47e255
to
263a04c
Compare
263a04c
to
7c2be9e
Compare
Did you already have an EventSource in .NET Core before this PR? I'm not sure what the backwards compat bar is on EventSource names. In any case, the perf counters (which are new) could go into a new EventSource as well with the new naming, even if that could be slightly confusing. |
...oft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
Outdated
Show resolved
Hide resolved
...oft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs
Show resolved
Hide resolved
...oft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs
Show resolved
Hide resolved
We are now looking at December and this was ready in September ... |
Hi @pi3k14, |
@DavoudEshtehari, maybe any help wanted on this one? |
Hi @DavoudEshtehari, I inspected the PR and see there are some tests in the EventCounterTest.cs. So there have to be more sophisticated tests or assertions? |
Hi @winseros, Happy holidays. 🙂 |
@DavoudEshtehari you may want to check out the event counter testing approach being done by @ajcvickers for EF in dotnet/efcore#23826. Actually setting up an EventListener may be quite flaky (and not to mention slow) - the idea is to simply use reflection to access the counters directly. |
Hi @roji, After checking the source code, we found EF core increment/decrement the inner variables without checking if |
@DavoudEshtehari the logic is that the increment/decrement is too cheap to justify the IsEnabled check (ASP.NET do the same with the event counters). In fact, logic branches (conditions) frequently turn out to be more expensive at the CPU level than the code they encompass. Note the difference with normal, non-polling event counters, where calling the method actually triggers the event being sent, as opposed to a simple increment/decrement. In that case the condition is indeed justified since sending the event is an expensive operation. |
* Fix minor typo * Removed IsEnabled condition and reformatted counter methods
* Implemented tests for Microsoft.Data.SqlClient.SqlClientEventSource * Updated the EventCounter test to reflect the recent changes in the code * Working on EventCounter tests access event counters through reflection * Updated the EventCounterTest to use reflection * Fixing dangling SqlConnection's left in tests * EventCountersTest now checks hard/soft connects/disconnects counters * Reverted the DataTestUtility changes * Reverted using statements to the old-style in tests * Reverted the ConnectionPoolTest.ReclaimEmancipatedOnOpenTest() * Reverted using statements to the old-style in tests * Reverted using statements to the old-style in tests * Rewrite the EventCounterTest assertions not to conflict with other tests * Code review cleanup
Is there something we could do to allow this merge request to make progress? I have a weird problem with connection pooling and can't diagnose it without Event counters. |
Added EventCounter_ReclaimedConnectionsCounter_Functional & EventCounter_ConnectionPoolGroupsCounter_Functional tests.
...crosoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just 1 pending suggestion, rest approved.
The following counters are added to
.Net core 3.1
,.Net standard 2.1
and above:For
Microsoft.Data.SqlClient.EventSource
, you can use .Net core global CLI tools:dotnet-counters
anddotnet-trace
in Windows or Linux and PerfView in Windows.related issue #523