Skip to content

How does Sentry's backend SDKs (ex. next.js) track of metadata across requests? #10082

Answered by AbhiPrasad
AbhiPrasad asked this question in Q&A
Discussion options

You must be logged in to vote

SDK Version at time of answer: 7.92.0

The Next.js SDK handles this automatically for you leveraging AsyncLocalStorage. Our other higher-level backend JS SDKs like SvelteKit, Remix, Serverless also handle this automatically.

If you're using Express, you need to use the Sentry request handler.

// RequestHandler creates a separate execution context, so that all
// transactions/spans/breadcrumbs are isolated across requests
app.use(Sentry.Handlers.requestHandler());

If you're using the plain Node SDK (or Bun or Deno), you'll can isolate a certain set of code via the runWithAsyncContext method. See: https://docs.sentry.io/platforms/node/configuration/async-context/ for more info.

const Sentry = 

Replies: 1 comment

Comment options

AbhiPrasad
Jan 5, 2024
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by AbhiPrasad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant