Skip to content
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

Adding EventSource to NetFx #399

Merged
merged 51 commits into from
Feb 27, 2020
Merged

Adding EventSource to NetFx #399

merged 51 commits into from
Feb 27, 2020

Conversation

JRahnama
Copy link
Member

This PR removes references to Bid class and replaces them with references to SqlClientEventSource.

@Wraith2
Copy link
Contributor

Wraith2 commented Jan 28, 2020

What consumes the messages that the BID tracing produced? There's a lot of information embedded in the strings and i'm not sure if it needs to remain in that format or if it could be split out as event properties so you can use them for filtering or grouping in consuming tools like perfview.

I'm not a big fan of the field access for the event source instance SqlClientEventSource._log.Trace feels like it should just be SqlClientEventSource.Trace and the method body should resolve the state parameter. I know a lot of the existing code works with internal variables in this way already but i've found that not having clean interfaces makes refactoring and understanding this library difficult at times because you can have instances reaching into each other's internals to do things you wouldn't normally expect.

@Wraith2
Copy link
Contributor

Wraith2 commented Jan 29, 2020

I had a read through https://github.com/Microsoft/dotnet-samples/blob/master/Microsoft.Diagnostics.Tracing/EventSource/docs/EventSource.md earlier and I think the new IfTaceEnabled method will need a [NoEvent] adding to it. Other than that the pattern looks better. The other trace like functions can be dealt with in the same way, by separating the condition check and real call out. And can _log be Log? in the doc it shows it as being publicly exposed and use directly so even though I think it'd look better if it were hidden the requirement for using instance methods means it can't be used that way.

@JRahnama
Copy link
Member Author

JRahnama commented Jan 29, 2020

@Wraith2 the IfTraceEnabled is marked as [NonEvent]. Initially, I started the the name with Log and VS got it as naming violation. _log/Log is an internal static read only instance of SqlClientEventSource. There are other versions of EventSource in NetFx. I got a bit confused when you mentioned doc. Is it Microsoft Docs or Driver documentation? There should not be any documentation about SqlClientEventSource as it is all internal.

@Wraith2
Copy link
Contributor

Wraith2 commented Jan 29, 2020

@Wraith2 the IfTraceEnabled is marked as [NonEvent]

Excellent, missed that then 😁

I started the the name with Log and VS got it as naming violation

Yeah, and it is. But it's a guideline and not a requirement and code is for humans to read so if the computer doesn't like it we can shut it up but the pattern of calling SqlClientEventSource._log.Trace just doesn't feel right to me. Just a suggestion though.

The doc I linked is the design/usage documentation from the original implementation. It was made for corefx and backported to netfx so the guidance there is first party and quite useful I found.

Copy link
Contributor

@David-Engel David-Engel left a comment

Choose a reason for hiding this comment

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

I haven't gotten all the way through yet, but wanted to post what I've done so far. In general, it looks good.

I generally agree with Wraith2 on naming it Log instead of _log for readability. I think we can suppress the naming violation.

As Wraith2 also mentioned, You need to surround _log.* calls with an if (_log.IsTraceEnabled()) block everywhere you are passing in a string that will be formatted before it is passed into the trace function to avoid the performance penalty of formatting and allocating a new string during the function call.

Copy link
Member

@cheenamalhotra cheenamalhotra left a comment

Choose a reason for hiding this comment

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

Need more changes.

@JRahnama JRahnama merged commit 5ed0d1a into dotnet:master Feb 27, 2020
cheenamalhotra pushed a commit to cheenamalhotra/SqlClient that referenced this pull request Mar 3, 2020
* EventTrace for NetFx, changes made to SqlConnection

* EventSource for NetFx

* Adding IsTraceEnabled

* EventSource NetFx to Review

* Taking unused variable out

* Ignore on .NetCore

* Update EventSourceTest.cs

* Adding if blocks

* EventSource

* Documentation

* Adding Tests and documentation

* Fixing Tests issues in NetCore

* moving from Functional to Manual Tests

* EventSource

* EventSource unwanted reference

* Taking extra documentation file out.

* Deleting unwanted file from NetCore

* EventSource

* Additional Improvments

* Taking the Static reference out

* Removing Extra lines and unwanted SqlClient Reference from SqlClientEventSource

* Changing documentation and adding Advanced Keyword

* Adding Overloaded methods in EventSource

* Fixing test issues

* more fixes

* EventSource

* ActivityCorrelator added.

* ActivityCorrelator added.

* fixing AdvanceTraceOn issues

* StateDump

* Removing if statement from code and placing them inside EventSource

* integrating SqlEventSource to SqlClientEventSource

* Adding null value checker to SqlDependencyListener EventSource logger

* EventSource

* Fixing ScopeLeave related logic

* Fixing PR issues and Tests

* EventSource

* EventSource

* EventSource

* Removing Doc

* ExceptionTrace Fix

* Update SqlAuthenticationProviderManager.cs

* Update SqlBulkCopy.cs

* Update SqlConnectionFactory.cs

* Update SqlConnectionPoolGroupProviderInfo.cs

* Update SqlCommand.cs
@JRahnama JRahnama deleted the EventSource branch August 24, 2021 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants