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

feat: use AsyncLocalStorage to track logger context #864

Merged
merged 14 commits into from
May 21, 2022
Merged

Conversation

samchungy
Copy link
Contributor

@samchungy samchungy commented May 14, 2022

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:

image

Performance hit of ~1.75% according to this which is negligible

nodejs/node#34493 (comment)

@changeset-bot
Copy link

changeset-bot bot commented May 14, 2022

🦋 Changeset detected

Latest commit: f1ba27f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
skuba Patch

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

@samchungy samchungy changed the title feat: use AsyncLocalStorage to track context feat: use AsyncLocalStorage to track logger context May 14, 2022
@samchungy samchungy marked this pull request as ready for review May 14, 2022 03:44
@samchungy samchungy requested review from a team as code owners May 14, 2022 03:44
Copy link
Member

@72636c 72636c left a 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.

.changeset/olive-worms-run.md Outdated Show resolved Hide resolved
@samchungy samchungy added the dino:snooze Snooze in Review Dino label May 18, 2022
@samchungy samchungy marked this pull request as draft May 20, 2022 03:03
@samchungy
Copy link
Contributor Author

Going to wait for the koala PR to go through before changing this to use that implementation.

@72636c 72636c removed the dino:snooze Snooze in Review Dino label May 21, 2022
@samchungy samchungy marked this pull request as ready for review May 21, 2022 02:12
Copy link
Member

@72636c 72636c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

.changeset/olive-worms-run.md Show resolved Hide resolved
72636c added a commit that referenced this pull request May 21, 2022
Co-authored-by: Ryan Ling <[email protected]>
@samchungy samchungy enabled auto-merge (squash) May 21, 2022 05:15
@samchungy samchungy merged commit b1f1e85 into master May 21, 2022
@samchungy samchungy deleted the async-logger branch May 21, 2022 05:20
@seek-oss-ci seek-oss-ci mentioned this pull request May 21, 2022
72636c added a commit that referenced this pull request May 24, 2022
* Steal #864 for lambda-sqs-worker

* Add changeset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants