feat(node): Add docs for async context apis#6641
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
shanamatthews
left a comment
There was a problem hiding this comment.
Looks great! I'm curious why you chose Koa as the example to show this on.
Co-authored-by: Shana Matthews <shana.l.matthews@gmail.com>
We actually don't have a koa integration, so the koa docs are a guide on how to manually instrument the framework with sentry. The example with |
| }, | ||
| }); | ||
| Sentry.runWithAsyncContext( | ||
| async hub => { |
There was a problem hiding this comment.
A question about this API: Why do we pass the hub as argument? Couldn't we just tell users to call Sentry.getCurrentHub() inside instead?
There was a problem hiding this comment.
We discussed offline and decided this was fine, since very few people are going to use this API anyway.
ref getsentry/sentry-javascript#7691
ref getsentry/sentry-javascript#7817
In the new upcoming version of the Node SDK, we now expose an API allowing users to isolate their requests to prevent breadcrumbs/tags/spans from leaking across requests. This PR documents that.
Before users had to manually use Node's domains API to do this, but now we've abstracted this away from them. To make this easier, we've updated the Koa docs to stop using domains directly, but instead use the new
runWithAsyncContextAPI.Note: only merge when
7.48.0is released.