-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Issue correct Enable/Disable commands for EventSources with EventPipe #81867
Conversation
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.
I like the direction. More comments on the details inline. Thanks @davmason!
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs
Outdated
Show resolved
Hide resolved
391ba78
to
be07d2e
Compare
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.
👍
…acing/EventProvider.cs Co-authored-by: Noah Falk <noahfalk@users.noreply.github.com>
…, and fix session_id
7e03a56
to
c76a33c
Compare
There were more failures than I'm comfortable merging with, rebasing against the latest in main |
ETW has the behavior that if multiple sessions are open the control code will always be 1 (Enable) in the callback: https://learn.microsoft.com/en-us/windows/win32/api/evntprov/nc-evntprov-penablecallback
We have code in EventSource.DoCommand() that detects this and changes the command sent to a Disable if a session is closing by checking the per session id:
runtime/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs
Line 2601 in 232fbce
However, EventPipe did not set this up properly. We would detect that it was an EventPipe session by checking if the return value from GetSessions() was empty, and then create a placeholder session:
runtime/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs
Lines 231 to 232 in 232fbce
But this session would always have the per session id of 0, so it would not trigger the Enable->Disable logic in DoCommand(). The end result is that if you had 3 sessions enabled and then disabled, you would get 5 Enable commands and one Disable command.
This PR does the following
Partial fix for #61353, there is still a bug in EventListener that means Disable won't be sent