Skip to content

fix(nextjs): Fix navigation tracing on app router #10502

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

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test('Creates a navigation transaction for app router routes', async ({ page })
);
});

const servercomponentTransactionPromise = waitForTransaction('nextjs-13-app-dir', async transactionEvent => {
const serverComponentTransactionPromise = waitForTransaction('nextjs-13-app-dir', async transactionEvent => {
return (
transactionEvent?.transaction === 'Page Server Component (/server-component/parameter/[...parameters])' &&
(await clientNavigationTransactionPromise).contexts?.trace?.trace_id ===
Expand All @@ -48,5 +48,5 @@ test('Creates a navigation transaction for app router routes', async ({ page })
await page.getByText('/server-component/parameter/foo/bar/baz').click();

expect(await clientNavigationTransactionPromise).toBeDefined();
expect(await servercomponentTransactionPromise).toBeDefined();
expect(await serverComponentTransactionPromise).toBeDefined();
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
addTracingExtensions,
captureException,
getClient,
getCurrentScope,
handleCallbackErrors,
startSpanManual,
withIsolationScope,
Expand Down Expand Up @@ -59,6 +60,7 @@ export function wrapGenerationFunctionWithSentry<F extends (...args: any[]) => a

const propagationContext = commonObjectToPropagationContext(headers, incomingPropagationContext);
isolationScope.setPropagationContext(propagationContext);
getCurrentScope().setPropagationContext(propagationContext);

return startSpanManual(
{
Expand Down
2 changes: 2 additions & 0 deletions packages/nextjs/src/common/wrapServerComponentWithSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
addTracingExtensions,
captureException,
getCurrentScope,
handleCallbackErrors,
startSpanManual,
withIsolationScope,
Expand Down Expand Up @@ -51,6 +52,7 @@ export function wrapServerComponentWithSentry<F extends (...args: any[]) => any>

const propagationContext = commonObjectToPropagationContext(context.headers, incomingPropagationContext);
isolationScope.setPropagationContext(propagationContext);
getCurrentScope().setPropagationContext(propagationContext);

return startSpanManual(
{
Expand Down