Add workflow state watch to debug mode #1975
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Understanding the runtime state of each operator in the workflow can be one of the most confusing aspects of learning visual reactive programming. Here we aim to assist this learning and debugging process by introducing a "watch" feature to the editor debug mode.
There are two main components to the feature:
Diagnostics
namespace introducing components and types for counting the number of notifications, subscriptions and cancellations to each operator.Watch infrastructure
There are five main stages in the life of a subscription to an observable sequence:
Subscribe
: the observable receives a subscription from a downstream operatorOnNext
: the observable emits a new value notificationOnCompleted
: the observable terminates successfullyOnError
: the observable terminates exceptionallyUnsubscribe
: the subscription is disposed, either following termination or cancellationThese stages can all run in parallel for each observable. The new diagnostics infrastructure introduces components to count all these events in a thread-safe manner using the
InspectBuilder
output streams.A new
Watch
stream had to be introduced to reliably materialize cancellation. In general cancellation is not part of the Rx grammar and should not be relied upon for operator composition, but it can be invaluable to materialize these events for tracing and runtime monitoring.Since each operator can have an arbitrary number of multiple parallel subscriptions, we adopt a strategy for combining or aggregating the state of each sequence into a single value using the following rules:
The
Error
status has precedence overCompleted
, and both have precedence overCanceled
. Each of the status values is mapped into a visual annotation which is updated and overlaid periodically on top of each operator. TheNotifying
status will actively spin as long as values continue to be emitted.Watch Example
Caveats and limitations
Fixes #1859