-
Notifications
You must be signed in to change notification settings - Fork 34
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
feat: use AsyncLocalStorage
to track logger context
#864
Conversation
🦋 Changeset detectedLatest commit: f1ba27f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
AsyncLocalStorage
to track contextAsyncLocalStorage
to track logger context
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.
This looks excellent and it sounds like there is little performance penalty with Node.js 16: nodejs/node#34493 (comment). I think our Lambdas could similarly benefit from the same approach.
It's pretty trivial but I wonder if we should upstream something to https://github.com/seek-oss/koala to enforce this pattern.
Co-authored-by: Ryan Ling <[email protected]>
Going to wait for the koala PR to go through before changing this to use that implementation. |
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.
🚢
Co-authored-by: Ryan Ling <[email protected]>
This might be a little radical but overall improves the DX and allows users to not need to worry about passing a context object around and/or a context logger around the codebase.
Some local testing confirms
x-request-id
is still present:Performance hit of ~1.75% according to this which is negligible
nodejs/node#34493 (comment)