-
Notifications
You must be signed in to change notification settings - Fork 30
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
Message Tracing by metric log #34
Open
k-toumura
wants to merge
7
commits into
node-red:master
Choose a base branch
from
node-red-hitachi:message-trace-proposal
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fad9eb6
initial submission of message tracing design note
k-toumura 70ecddb
minor update
k-toumura 4ca6636
Merge remote-tracking branch 'upstream/master' into message-trace-pro…
k-toumura d64f055
use object for node.metric()
k-toumura 6ea8630
add example code of correlate metric
k-toumura 40495ba
Merge remote-tracking branch 'upstream/master' into message-trace-pro…
k-toumura c6687c8
Update usage example
k-toumura File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
--- | ||
state: draft | ||
--- | ||
|
||
# Message Tracing by metric log | ||
|
||
## Summary | ||
|
||
To enable precise tracing of each message, we propose to make the runtime emit | ||
log message whenever the message processing is finished. For more complex | ||
tracing for nodes which splitting or joining the messages, these nodes may | ||
emit a *correlation* log to provide information of | ||
which message is depend on another message. | ||
|
||
## Authors | ||
|
||
- @k-toumura | ||
|
||
## Details | ||
|
||
### Use case | ||
|
||
In debugging, we want to trace the messages. Currently, we use Debug nodes to confirm that a process in some node is finished. But: | ||
|
||
- we can't know whether the message is received and start processing in some node. | ||
- inserting Debug nodes is cumbersome process, and readability become worse. | ||
|
||
By enabling metric log, we can see message IDs that is sent/received. | ||
But, if the node doesn't send a message, we can't confirm that | ||
the processing in the node is finished. | ||
|
||
Moreover, if the node send a message asynchronously, it is difficult | ||
to analyze a causal relationship between messages. | ||
|
||
For example, there is a flow configured like following diagram: | ||
![sample flow](sampleflow.png) | ||
and the runtime emittted the following metric logs. | ||
![sample log](samplelog.png) | ||
|
||
Node "D" receives message "X", run join process, and then emit message to node "E", | ||
but, we can't confirm that messages "Y" and "Z" been processed, or still queued in node "D". | ||
|
||
### Requirement | ||
|
||
To trace a message, we should know: | ||
- when the processing of the message is finished. | ||
- which messages are related to the message. | ||
|
||
### Proposed changes | ||
|
||
#### Metric log for message process completion in a node | ||
|
||
Emit metric log when nodes calls `done()` callback, such like: | ||
``` | ||
26 Feb 09:33:26 - [metric] {"level":99,"nodeid":"8b1f2328.8e972","event":"node.join.done","msgid":"2522bce.e667944","timestamp":1582677206863} | ||
|
||
``` | ||
where: | ||
- nodeid: id of a node | ||
- event: `node.NODETYPE.done` | ||
- msgid: id of a message that the node has finished processing | ||
- timestamp: Unix time in millisecond | ||
|
||
#### Metric log to correlate between messages | ||
|
||
Emit metric log when sent a message which is related to other messages using: | ||
``` | ||
node.metric("correlate", msg, relatedMsgIds) | ||
``` | ||
where: | ||
- msg: message in process. For example, when join node send a concatenated message, use the message as an argument of `node.metric()`. | ||
- relatedMsgIds: array of ids of related messages. | ||
|
||
Note: we can put more complex information on the third argument of `node.metric()`. For example, we can make it a object which contains a array of message ids and a relation type such as `"isPartOf"`, `"splitInto"`, `"isDependsOn"`, etc. | ||
|
||
### Usage example | ||
|
||
For the example shown in Use cases, the proposed metric logging makes message traceable. | ||
|
||
![Correlation](correlationlog.png) | ||
|
||
- by `node.join.correlate` event, we can assume that message X is related to message Y and Z. | ||
- by `node.join.done` event, we can assume that processing of message X, Y and Z are completed. | ||
|
||
## Related topics | ||
|
||
- [Metrics Usage design note](../metrics-usage.md) | ||
- [Graceful Shutdown design note](../gracerul-shutdown/README.md) | ||
- [Pluggable Message Routing](../pluggable-message-routing.md) | ||
|
||
## History | ||
|
||
- 2020-07-14 - Initial proposal submitted | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
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 think we need to decide if it's going to be a more complex object from the start - it isn't something we can change later.
In the Join node scenario, which is the main scenario that requires this
correlate
metric, I would suggest it looks like:That gives us room to introduce other correlate messages if they prove necessary.