Skip to content

Commit ab6d376

Browse files
committed
pass request to tracesSampler when starting transaction in data-fetcher wrappers
1 parent 19c4fb1 commit ab6d376

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

packages/nextjs/src/config/wrappers/wrapperUtils.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,19 @@ export function callTracedServerSideDataFetcher<F extends (...args: any[]) => Pr
9393

9494
const dynamicSamplingContext = baggageHeaderToDynamicSamplingContext(rawBaggageString);
9595

96-
const newTransaction = startTransaction({
97-
op: 'nextjs.data.server',
98-
name: options.requestedRouteName,
99-
...traceparentData,
100-
status: 'ok',
101-
metadata: {
102-
source: 'route',
103-
dynamicSamplingContext: traceparentData && !dynamicSamplingContext ? {} : dynamicSamplingContext,
96+
const newTransaction = startTransaction(
97+
{
98+
op: 'nextjs.data.server',
99+
name: options.requestedRouteName,
100+
...traceparentData,
101+
status: 'ok',
102+
metadata: {
103+
source: 'route',
104+
dynamicSamplingContext: traceparentData && !dynamicSamplingContext ? {} : dynamicSamplingContext,
105+
},
104106
},
105-
});
107+
{ request: req },
108+
);
106109

107110
requestTransaction = newTransaction;
108111
autoEndTransactionOnResponseEnd(newTransaction, res);

packages/nextjs/test/config/wrappers.test.ts

+10
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ describe('data-fetching function wrappers', () => {
4545
op: 'nextjs.data.server',
4646
metadata: expect.objectContaining({ source: 'route' }),
4747
}),
48+
{
49+
request: expect.objectContaining({
50+
url: 'http://dogs.are.great/tricks/kangaroo',
51+
}),
52+
},
4853
);
4954

5055
expect(setMetadataSpy).toHaveBeenCalledWith({ request: req });
@@ -62,6 +67,11 @@ describe('data-fetching function wrappers', () => {
6267
op: 'nextjs.data.server',
6368
metadata: expect.objectContaining({ source: 'route' }),
6469
}),
70+
{
71+
request: expect.objectContaining({
72+
url: 'http://dogs.are.great/tricks/kangaroo',
73+
}),
74+
},
6575
);
6676

6777
expect(setMetadataSpy).toHaveBeenCalledWith({ request: req });

0 commit comments

Comments
 (0)