Add async sequence ID
gajus opened this issue ยท 1 comments
Related to this issue: #43
Premise
It may be desired to track sequence in which events are taking place, e.g.
const request = (url) => {
log('foo %s', url);
setTimeout(() => {
log('bar %s', url);
}, Math.random());
};
Promise.all([
request('https://a'),
request('https://b'),
]);
This requirement is already achieved using sequence
:
{"time":1,"sequence":1,"message":"foo https://a"}
{"time":1,"sequence":2,"message":"foo https://b"}
{"time":1,"sequence":3,"message":"bar https://b"}
{"time":1,"sequence":4,"message":"bar https://a"}
As a reminder, the current use case for sequence
is to allow sorting of sub-millisecond events (where time
alone cannot be used to distinguish event order).
Problem
However, in the above example, other than by analyzing message
values, it is not possible to tell how 3rd and 4th log entries relate to 1st and 2nd.
Solution
This problem could be solved by changing "sequence" field to include the ID of the parent sequence that was used to generate the logs, e.g.
{"time":1,"sequence":"1","message":"foo https://a"}
{"time":1,"sequence":"2","message":"foo https://b"}
{"time":1,"sequence":"2.1","message":"bar https://b"}
{"time":1,"sequence":"1.1","message":"bar https://a"}
This format allows to continue using sequence
for sorting sub-millisecond events, but it also adds ability to identify the origin of the events.
Discussion
This is the first (breaking or any) change to the log format since the release of Roarr.
- Is this a valuable addition?
- Is there a better way to implement the desired functionality?
๐ This issue has been resolved in version 6.0.0 ๐
The release is available on:
Your semantic-release bot ๐ฆ๐