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(node): Add docs for async context apis #6641

Merged
merged 4 commits into from
Apr 14, 2023

Conversation

AbhiPrasad
Copy link
Member

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 runWithAsyncContext API.

Note: only merge when 7.48.0 is released.

@AbhiPrasad AbhiPrasad requested review from shanamatthews, a team, mydea and lforst and removed request for a team April 12, 2023 09:36
@vercel
Copy link

vercel bot commented Apr 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 13, 2023 2:38pm

Copy link
Contributor

@shanamatthews shanamatthews left a comment

Choose a reason for hiding this comment

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

Looks great! I'm curious why you chose Koa as the example to show this on.

src/platforms/node/common/configuration/async-context.mdx Outdated Show resolved Hide resolved
@AbhiPrasad
Copy link
Member Author

Looks great! I'm curious why you chose Koa as the example to show this on.

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 requestHandlerMiddleware should be fairly agnostic to node frameworks across the board, so we should be fine there.

src/platforms/node/common/configuration/async-context.mdx Outdated Show resolved Hide resolved
src/platforms/node/common/configuration/async-context.mdx Outdated Show resolved Hide resolved
src/platforms/node/guides/express/index.mdx Outdated Show resolved Hide resolved
},
});
Sentry.runWithAsyncContext(
async hub => {
Copy link
Member

Choose a reason for hiding this comment

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

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

We discussed offline and decided this was fine, since very few people are going to use this API anyway.

@AbhiPrasad AbhiPrasad merged commit 1a7626f into master Apr 14, 2023
@AbhiPrasad AbhiPrasad deleted the abhi-async-context-public-api branch April 14, 2023 10:31
kamilkisiela added a commit to graphql-hive/console that referenced this pull request Apr 17, 2023
kamilkisiela added a commit to graphql-hive/console that referenced this pull request Apr 17, 2023
kamilkisiela added a commit to graphql-hive/console that referenced this pull request Apr 17, 2023
kamilkisiela added a commit to graphql-hive/console that referenced this pull request Apr 19, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants