Skip to content

Commit e55496e

Browse files
committed
ref(node): Add propagations to http integration
fix tests rename name_changes -> changes remaining nameChanges ref(node): Add propagations to http integration fix nextjs tests
1 parent 249e64d commit e55496e

File tree

14 files changed

+72
-1
lines changed

14 files changed

+72
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ module.exports = async ({ url: urlBase, argv }) => {
1818
transaction: 'GET /api/users',
1919
transaction_info: {
2020
source: 'route',
21+
changes: [],
22+
propagations: 0,
2123
},
2224
type: 'transaction',
2325
request: {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ module.exports = async ({ url: urlBase, argv }) => {
1717
transaction: 'GET /api/broken',
1818
transaction_info: {
1919
source: 'route',
20+
changes: [],
21+
propagations: 0,
2022
},
2123
type: 'transaction',
2224
request: {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ module.exports = async ({ url: urlBase, argv }) => {
3131
transaction: 'GET /api/http',
3232
transaction_info: {
3333
source: 'route',
34+
changes: [],
35+
propagations: 1,
3436
},
3537
type: 'transaction',
3638
request: {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ module.exports = async ({ url: urlBase, argv }) => {
1616
transaction: '/[id]/withInitialProps',
1717
transaction_info: {
1818
source: 'route',
19+
changes: [],
20+
propagations: 0,
1921
},
2022
type: 'transaction',
2123
request: {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ module.exports = async ({ url: urlBase, argv }) => {
1616
transaction: '/[id]/withServerSideProps',
1717
transaction_info: {
1818
source: 'route',
19+
changes: [],
20+
propagations: 0,
1921
},
2022
type: 'transaction',
2123
request: {

packages/node-integration-tests/suites/express/tracing/test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ test('should set a correct transaction name for routes specified in RegEx', asyn
3838
transaction: 'GET /\\/test\\/regex/',
3939
transaction_info: {
4040
source: 'route',
41+
changes: [],
42+
propagations: 0,
4143
},
4244
contexts: {
4345
trace: {
@@ -66,6 +68,8 @@ test.each([['array1'], ['array5']])(
6668
transaction: 'GET /test/array1,/\\/test\\/array[2-9]',
6769
transaction_info: {
6870
source: 'route',
71+
changes: [],
72+
propagations: 0,
6973
},
7074
contexts: {
7175
trace: {
@@ -102,6 +106,8 @@ test.each([
102106
transaction: 'GET /test/arr/:id,/\\/test\\/arr[0-9]*\\/required(path)?(\\/optionalPath)?\\/(lastParam)?',
103107
transaction_info: {
104108
source: 'route',
109+
changes: [],
110+
propagations: 0,
105111
},
106112
contexts: {
107113
trace: {

packages/node/src/integrations/http.ts

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

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

packages/remix/test/integration/test/server/loader.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
5555
transaction: 'routes/loader-json-response/$id',
5656
transaction_info: {
5757
source: 'route',
58+
changes: [],
59+
propagations: 0,
5860
},
5961
spans: [
6062
{

packages/tracing/src/transaction.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export class Transaction extends SpanClass implements TransactionInterface {
4545
this.metadata = {
4646
...transactionContext.metadata,
4747
spanMetadata: {},
48+
changes: [],
49+
propagations: 0,
4850
};
4951

5052
this._trimEnd = transactionContext.trimEnd;
@@ -156,6 +158,8 @@ export class Transaction extends SpanClass implements TransactionInterface {
156158
...(metadata.source && {
157159
transaction_info: {
158160
source: metadata.source,
161+
changes: metadata.changes,
162+
propagations: metadata.propagations,
159163
},
160164
}),
161165
};

0 commit comments

Comments
 (0)