-
Notifications
You must be signed in to change notification settings - Fork 752
Extend PredefinedDynamicTraceEventParser to Support Dynamic Events from EventPipeEventSource #2232
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
Conversation
Co-authored-by: brianrob <6210322+brianrob@users.noreply.github.com>
|
@copilot, this code looks correct. I'd now like for you to update |
…micTraceEventParser Co-authored-by: brianrob <6210322+brianrob@users.noreply.github.com>
I've updated
The implementation provides both dynamic event support (for EventPipe sources) and backward compatibility for existing code. Commit: 87a570a |
|
@copilot please update the |
Co-authored-by: brianrob <6210322+brianrob@users.noreply.github.com>
I've updated the
The events now properly leverage the |
| { | ||
| // Parse event metadata. | ||
| DynamicTraceEventData dynamicTraceEventData = RegisteredTraceEventParser.TryLookupWorker(data); | ||
| // Parse event metadata based on the source type |
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.
There is a more structural problem here that I hadn't appreciated. PredefinedDynamicTraceEventParser has an implementation that handles unknown events, and so does ExternalTraceEventParser. I think we should make PredefinedDynamicTraceEventParser inherit from ExternalTraceEventParser and that way it can use the implementation for unknown events in ExternalTraceEventParser. This will also require changing the implementation of ExternalTraceEventParser - specifically the implementation of delegate passed to RegisterUnhandledEvent so that it can find both events in the ExternalTraceEventParserState and those in PredefinedDynamicTraceEventParser. I think that we should be able to merge their implementations into ExternalTraceEventParser instead of having a separate implementation in PredefinedDynamicTraceEventParser.
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've refactored the architecture as requested. Changes made:
- Changed inheritance:
PredefinedDynamicTraceEventParsernow inherits fromExternalTraceEventParserinstead ofTraceEventParser - Implemented
TryLookup: Replaced the customOnUnhandledEventhandler with the standardTryLookupmethod - Eliminated duplication: Removed the separate unhandled event registration logic
- Unified implementation: Both ETW and EventPipe event metadata parsing now use the same
ExternalTraceEventParserframework
The implementations are now merged - ExternalTraceEventParser handles the unhandled event registration, and PredefinedDynamicTraceEventParser.TryLookup provides the predefined dynamic event lookup. This eliminates the structural problem while maintaining all existing functionality.
Commit: 618992c
PredefinedDynamicTraceEventParser. Ensure we don't spend lots of time decoding metadata over and over.
618992c to
4fb67c1
Compare
repro/Program.cs
Outdated
| using Microsoft.Diagnostics.Tracing.Parsers; | ||
| using Microsoft.Diagnostics.Tracing.Parsers.Universal.Events; | ||
|
|
||
| string inputFileName = args[0]; |
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.
@copilot, this file contains a standalone repro test case that can be built and run, passing in an argument with the path to repro.nettrace.
Current Behavior: If an instance of DynamicParser is used to parse an event, then the event is not properly dispatched to the UniversalEventsTraceEventParser. For this repro case, the CPU events are written to the console with the prefix "Dynamic Parser:".
Expected Behavior: I expect the events to be dispatched by both the DynamicTraceEventParser and the UniversalEventsTraceEventParser if they both register to receive the event. Thus for cpu events, I expect to see console output that is prefixed by Dynamic Parser: and then on a separate line CPU:. Which of these prefixes shows up first does not matter.
Given that this is not working, can you please build and run the test case, confirm that is not working, and see if you can develop a fix.
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've confirmed the issue and identified the root cause. The problem occurs when both DynamicTraceEventParser and UniversalEventsTraceEventParser register handlers for the same event - only one parser receives the events due to template registration conflicts.
Key Findings:
- ✅
UniversalEventsTraceEventParserworks correctly when used alone - ✅ Both parsers work when handling different events
- ❌ When both handle the same event, only the first-registered parser gets events
Current Status:
I've made partial fixes to the template registration mechanism, but the core issue with multiple parsers handling identical events still needs to be resolved. The template chaining logic exists but appears to have dispatch issues.
Working on a complete solution to ensure both parsers can receive the same events simultaneously. Commit: 37104ad
pulled from the serialized dynamic event information.
7bae616 to
87063b0
Compare
|
Copilot Post-Mortem:
|
marklio
left a comment
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.
Looks good. I have a preference for new C# features that reduce the boilerplate on alot of this, but this seems like it should work.
Thanks much! I was thinking I might do an experiment to bump the language version and see what kinds of readability improvements we can make. |
This PR extends
PredefinedDynamicTraceEventParserto support dynamic events fromEventPipeEventSourcein addition toETWTraceEventSource. It also updatesUniversalEventsTraceEventParserto use this functionality because it follows the self-describing pattern of not using fixed event IDs.Fixes #2231.