Skip to content

Commit 8cff038

Browse files
authored
ref(node): Add propagations to http integration (#5720)
This PR updates the propagations metadata field in the node SDK for the HTTP integration.
1 parent 60b394a commit 8cff038

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

packages/nextjs/test/integration/test/server/tracingHttp.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = async ({ url: urlBase, argv }) => {
3232
transaction_info: {
3333
source: 'route',
3434
changes: [],
35-
propagations: 0,
35+
propagations: 1,
3636
},
3737
type: 'transaction',
3838
request: {

packages/node/src/integrations/http.ts

+5
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ function _createWrappedRequestMethodFactory(
172172
`[Tracing] Not adding sentry-trace header to outgoing request (${requestUrl}) due to mismatching tracePropagationTargets option.`,
173173
);
174174
}
175+
176+
const transaction = parentSpan.transaction;
177+
if (transaction) {
178+
transaction.metadata.propagations += 1;
179+
}
175180
}
176181
}
177182

packages/node/test/integrations/http.test.ts

+14
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,20 @@ describe('tracing', () => {
172172
expect(baggage).not.toBeDefined();
173173
});
174174

175+
it('records outgoing propagations on the transaction', () => {
176+
nock('http://dogs.are.great').get('/').reply(200);
177+
178+
const transaction = createTransactionOnScope();
179+
180+
expect(transaction.metadata.propagations).toBe(0);
181+
182+
http.get('http://dogs.are.great/');
183+
expect(transaction.metadata.propagations).toBe(1);
184+
185+
http.get('http://dogs.are.great/');
186+
expect(transaction.metadata.propagations).toBe(2);
187+
});
188+
175189
describe('tracePropagationTargets option', () => {
176190
beforeEach(() => {
177191
// hacky way of restoring monkey patched functions

0 commit comments

Comments
 (0)