Repository navigation
Non-blocking EventPipeEventSource Ctor - #1588
Brian Robbins (brianrob) merged 4 commits into
Conversation
I'd say throwing is desirable if the values aren't initialized yet, but if it was a significant hassle to implement I don't think it would be awful to return some default 0/null/empty string values instead. What do you think Brian Robbins (@brianrob)? |
Agreed. There are Depending on Brian Robbins (@brianrob)'s thoughts, I'll look at making these properties throw if |
|
I would tend to agree that if there is metadata that can't be filled before returning from the constructor, then throwing is a good idea. If you look at how we handle realtime ETW sessions, the session is created and setup before you get the source from it, which means that the source can make calls to the session to get metadata. Would such a pattern help here? If not, I would say throwing is the next best thing. |
I think yes, however, the API for configuring, starting, and stopping an EventPipe session is in the diagnostics client library and not in TraceEvent. That makes it a little more complicated to make this pattern happen. Right now, the flow for "trace on startup" is this:
In the "trace on startup" scenario, we need to wait for the target process to resume before the session starts. Without this change, the ctor call in step 3 would block until we resume the target. After this change, the ctor would complete, but the metadata wouldn't be populated yet. Any usage of that |
|
Gotcha. So this becomes a bit more complicated. I think it is OK to simplify and just throw in APIs that don't have data yet. Just wanted to make sure that there wasn't another pattern that might help. |
|
John Salem (@josalem), I see that you just pushed another commit here. Please let me know when this is ready for another review, or is ready for merge. Thanks. |
|
I think this is ready for final review and merge at your discretion. |
This PR makes the constructor for
EventPipeEventSourcenon-blocking. Previously, the constructor would block until data was sent on the stream. This bringsEventPipeEventSourcecloser in behavior to other similar APIs in the TraceEvent library.One issue that isn't solved by this PR (yet) is that we need to handle the case where users try to get metadata about the source before data arrives. Before this PR, users were guaranteed to have that information when the ctor returned. Now, this is only true for opening a completed file, hence the special casing for files. Currently, this PR makes no attempt to stop users from reading metadata properties. I am hoping for some feedback on whether this should throw an exception or now. Until this is decided, I'll leave this in draft mode.I'm going to leave this alone for now, and address it if users are hitting this behavior. The only use case for these Properties seems to be covered fine by differentiating streaming vs non-streaming.fixes #1172