Skip to content
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

Add async sequence ID #44

Closed
gajus opened this issue Jun 23, 2021 · 1 comment
Closed

Add async sequence ID #44

gajus opened this issue Jun 23, 2021 · 1 comment

Comments

@gajus
Copy link
Owner

gajus commented Jun 23, 2021

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?
@gajus
Copy link
Owner Author

gajus commented Jun 24, 2021

🎉 This issue has been resolved in version 6.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant