Skip to content

Commit b0e42b9

Browse files
committed
pass request to tracesSampler when starting transaction in data-fetcher wrappers
1 parent 83698eb commit b0e42b9

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,18 @@ export function callTracedServerSideDataFetcher<F extends (...args: any[]) => Pr
9393

9494
const baggage = parseBaggageSetMutability(rawBaggageString, traceparentData);
9595

96-
const newTransaction = startTransaction({
97-
op: 'nextjs.data.server',
98-
name: options.requestedRouteName,
99-
...traceparentData,
100-
metadata: {
101-
source: 'route',
102-
baggage,
96+
const newTransaction = startTransaction(
97+
{
98+
op: 'nextjs.data.server',
99+
name: options.requestedRouteName,
100+
...traceparentData,
101+
metadata: {
102+
source: 'route',
103+
baggage,
104+
},
103105
},
104-
});
106+
{ request: req },
107+
);
105108

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

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

Lines changed: 10 additions & 0 deletions
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)