Skip to content

Commit 8bb4ff8

Browse files
onurtemizkanmydea
authored andcommitted
Fix formatting.
1 parent 14d577a commit 8bb4ff8

File tree

5 files changed

+79
-155
lines changed

5 files changed

+79
-155
lines changed

dev-packages/e2e-tests/test-applications/node-nestjs-app/src/app.service.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,13 @@ export class AppService1 {
2222
}
2323

2424
async testOutgoingHttp(id: string) {
25-
const data = await makeHttpRequest(
26-
`http://localhost:3030/test-inbound-headers/${id}`,
27-
);
25+
const data = await makeHttpRequest(`http://localhost:3030/test-inbound-headers/${id}`);
2826

2927
return data;
3028
}
3129

3230
async testOutgoingFetch(id: string) {
33-
const response = await fetch(
34-
`http://localhost:3030/test-inbound-headers/${id}`,
35-
);
31+
const response = await fetch(`http://localhost:3030/test-inbound-headers/${id}`);
3632
const data = await response.json();
3733

3834
return data;
@@ -63,9 +59,7 @@ export class AppService1 {
6359
}
6460

6561
async testOutgoingFetchExternalDisallowed() {
66-
const fetchResponse = await fetch(
67-
'http://localhost:3040/external-disallowed',
68-
);
62+
const fetchResponse = await fetch('http://localhost:3040/external-disallowed');
6963

7064
return fetchResponse.json();
7165
}

dev-packages/e2e-tests/test-applications/node-nestjs-app/src/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import * as http from 'http';
22

33
export function makeHttpRequest(url) {
4-
return new Promise((resolve) => {
4+
return new Promise(resolve => {
55
const data = [];
66

77
http
8-
.request(url, (httpRes) => {
9-
httpRes.on('data', (chunk) => {
8+
.request(url, httpRes => {
9+
httpRes.on('data', chunk => {
1010
data.push(chunk);
1111
});
12-
httpRes.on('error', (error) => {
12+
httpRes.on('error', error => {
1313
resolve({ error: error.message, url });
1414
});
1515
httpRes.on('end', () => {

dev-packages/e2e-tests/test-applications/node-nestjs-app/tests/errors.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,8 @@ test('Sends captured error to Sentry', async ({ baseURL }) => {
4242
});
4343

4444
test('Sends exception to Sentry', async ({ baseURL }) => {
45-
const errorEventPromise = waitForError('node-nestjs-app', (event) => {
46-
return (
47-
!event.type &&
48-
event.exception?.values?.[0]?.value === 'This is an exception'
49-
);
45+
const errorEventPromise = waitForError('node-nestjs-app', event => {
46+
return !event.type && event.exception?.values?.[0]?.value === 'This is an exception';
5047
});
5148

5249
try {

dev-packages/e2e-tests/test-applications/node-nestjs-app/tests/propagation.test.ts

Lines changed: 64 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,27 @@ import { waitForTransaction } from '../event-proxy-server';
77
test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
88
const id = crypto.randomUUID();
99

10-
const inboundTransactionPromise = waitForTransaction(
11-
'node-nestjs-app',
12-
(transactionEvent) => {
13-
return (
14-
transactionEvent.contexts?.trace?.op === 'http.server' &&
15-
transactionEvent.contexts?.trace?.data?.['http.target'] ===
16-
`/test-inbound-headers/${id}`
17-
);
18-
},
19-
);
10+
const inboundTransactionPromise = waitForTransaction('node-nestjs-app', transactionEvent => {
11+
return (
12+
transactionEvent.contexts?.trace?.op === 'http.server' &&
13+
transactionEvent.contexts?.trace?.data?.['http.target'] === `/test-inbound-headers/${id}`
14+
);
15+
});
2016

21-
const outboundTransactionPromise = waitForTransaction(
22-
'node-nestjs-app',
23-
(transactionEvent) => {
24-
return (
25-
transactionEvent.contexts?.trace?.op === 'http.server' &&
26-
transactionEvent.contexts?.trace?.data?.['http.target'] ===
27-
`/test-outgoing-http/${id}`
28-
);
29-
},
30-
);
17+
const outboundTransactionPromise = waitForTransaction('node-nestjs-app', transactionEvent => {
18+
return (
19+
transactionEvent.contexts?.trace?.op === 'http.server' &&
20+
transactionEvent.contexts?.trace?.data?.['http.target'] === `/test-outgoing-http/${id}`
21+
);
22+
});
3123

3224
const { data } = await axios.get(`${baseURL}/test-outgoing-http/${id}`);
3325

3426
const inboundTransaction = await inboundTransactionPromise;
3527
const outboundTransaction = await outboundTransactionPromise;
3628

3729
const traceId = outboundTransaction?.contexts?.trace?.trace_id;
38-
const outgoingHttpSpan = outboundTransaction?.spans?.find(
39-
(span) => span.op === 'http.client',
40-
) as SpanJSON | undefined;
30+
const outgoingHttpSpan = outboundTransaction?.spans?.find(span => span.op === 'http.client') as SpanJSON | undefined;
4131

4232
expect(outgoingHttpSpan).toBeDefined();
4333

@@ -49,9 +39,7 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
4939
const inboundHeaderSentryTrace = data.headers?.['sentry-trace'];
5040
const inboundHeaderBaggage = data.headers?.['baggage'];
5141

52-
expect(inboundHeaderSentryTrace).toEqual(
53-
`${traceId}-${outgoingHttpSpanId}-1`,
54-
);
42+
expect(inboundHeaderSentryTrace).toEqual(`${traceId}-${outgoingHttpSpanId}-1`);
5543
expect(inboundHeaderBaggage).toBeDefined();
5644

5745
const baggage = (inboundHeaderBaggage || '').split(',');
@@ -133,37 +121,27 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
133121
test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
134122
const id = crypto.randomUUID();
135123

136-
const inboundTransactionPromise = waitForTransaction(
137-
'node-nestjs-app',
138-
(transactionEvent) => {
139-
return (
140-
transactionEvent?.contexts?.trace?.op === 'http.server' &&
141-
transactionEvent.contexts?.trace?.data?.['http.target'] ===
142-
`/test-inbound-headers/${id}`
143-
);
144-
},
145-
);
124+
const inboundTransactionPromise = waitForTransaction('node-nestjs-app', transactionEvent => {
125+
return (
126+
transactionEvent?.contexts?.trace?.op === 'http.server' &&
127+
transactionEvent.contexts?.trace?.data?.['http.target'] === `/test-inbound-headers/${id}`
128+
);
129+
});
146130

147-
const outboundTransactionPromise = waitForTransaction(
148-
'node-nestjs-app',
149-
(transactionEvent) => {
150-
return (
151-
transactionEvent?.contexts?.trace?.op === 'http.server' &&
152-
transactionEvent.contexts?.trace?.data?.['http.target'] ===
153-
`/test-outgoing-fetch/${id}`
154-
);
155-
},
156-
);
131+
const outboundTransactionPromise = waitForTransaction('node-nestjs-app', transactionEvent => {
132+
return (
133+
transactionEvent?.contexts?.trace?.op === 'http.server' &&
134+
transactionEvent.contexts?.trace?.data?.['http.target'] === `/test-outgoing-fetch/${id}`
135+
);
136+
});
157137

158138
const { data } = await axios.get(`${baseURL}/test-outgoing-fetch/${id}`);
159139

160140
const inboundTransaction = await inboundTransactionPromise;
161141
const outboundTransaction = await outboundTransactionPromise;
162142

163143
const traceId = outboundTransaction?.contexts?.trace?.trace_id;
164-
const outgoingHttpSpan = outboundTransaction?.spans?.find(
165-
(span) => span.op === 'http.client',
166-
) as SpanJSON | undefined;
144+
const outgoingHttpSpan = outboundTransaction?.spans?.find(span => span.op === 'http.client') as SpanJSON | undefined;
167145

168146
expect(outgoingHttpSpan).toBeDefined();
169147

@@ -175,9 +153,7 @@ test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
175153
const inboundHeaderSentryTrace = data.headers?.['sentry-trace'];
176154
const inboundHeaderBaggage = data.headers?.['baggage'];
177155

178-
expect(inboundHeaderSentryTrace).toEqual(
179-
`${traceId}-${outgoingHttpSpanId}-1`,
180-
);
156+
expect(inboundHeaderSentryTrace).toEqual(`${traceId}-${outgoingHttpSpanId}-1`);
181157
expect(inboundHeaderBaggage).toBeDefined();
182158

183159
const baggage = (inboundHeaderBaggage || '').split(',');
@@ -256,30 +232,20 @@ test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
256232
});
257233
});
258234

259-
test('Propagates trace for outgoing external http requests', async ({
260-
baseURL,
261-
}) => {
262-
const inboundTransactionPromise = waitForTransaction(
263-
'node-nestjs-app',
264-
(transactionEvent) => {
265-
return (
266-
transactionEvent?.contexts?.trace?.op === 'http.server' &&
267-
transactionEvent.contexts?.trace?.data?.['http.target'] ===
268-
`/test-outgoing-http-external-allowed`
269-
);
270-
},
271-
);
235+
test('Propagates trace for outgoing external http requests', async ({ baseURL }) => {
236+
const inboundTransactionPromise = waitForTransaction('node-nestjs-app', transactionEvent => {
237+
return (
238+
transactionEvent?.contexts?.trace?.op === 'http.server' &&
239+
transactionEvent.contexts?.trace?.data?.['http.target'] === `/test-outgoing-http-external-allowed`
240+
);
241+
});
272242

273-
const { data } = await axios.get(
274-
`${baseURL}/test-outgoing-http-external-allowed`,
275-
);
243+
const { data } = await axios.get(`${baseURL}/test-outgoing-http-external-allowed`);
276244

277245
const inboundTransaction = await inboundTransactionPromise;
278246

279247
const traceId = inboundTransaction?.contexts?.trace?.trace_id;
280-
const spanId = inboundTransaction?.spans?.find(
281-
(span) => span.op === 'http.client',
282-
)?.span_id;
248+
const spanId = inboundTransaction?.spans?.find(span => span.op === 'http.client')?.span_id;
283249

284250
expect(traceId).toEqual(expect.any(String));
285251
expect(spanId).toEqual(expect.any(String));
@@ -302,30 +268,20 @@ test('Propagates trace for outgoing external http requests', async ({
302268
);
303269
});
304270

305-
test('Does not propagate outgoing http requests not covered by tracePropagationTargets', async ({
306-
baseURL,
307-
}) => {
308-
const inboundTransactionPromise = waitForTransaction(
309-
'node-nestjs-app',
310-
(transactionEvent) => {
311-
return (
312-
transactionEvent?.contexts?.trace?.op === 'http.server' &&
313-
transactionEvent.contexts?.trace?.data?.['http.target'] ===
314-
`/test-outgoing-http-external-disallowed`
315-
);
316-
},
317-
);
271+
test('Does not propagate outgoing http requests not covered by tracePropagationTargets', async ({ baseURL }) => {
272+
const inboundTransactionPromise = waitForTransaction('node-nestjs-app', transactionEvent => {
273+
return (
274+
transactionEvent?.contexts?.trace?.op === 'http.server' &&
275+
transactionEvent.contexts?.trace?.data?.['http.target'] === `/test-outgoing-http-external-disallowed`
276+
);
277+
});
318278

319-
const { data } = await axios.get(
320-
`${baseURL}/test-outgoing-http-external-disallowed`,
321-
);
279+
const { data } = await axios.get(`${baseURL}/test-outgoing-http-external-disallowed`);
322280

323281
const inboundTransaction = await inboundTransactionPromise;
324282

325283
const traceId = inboundTransaction?.contexts?.trace?.trace_id;
326-
const spanId = inboundTransaction?.spans?.find(
327-
(span) => span.op === 'http.client',
328-
)?.span_id;
284+
const spanId = inboundTransaction?.spans?.find(span => span.op === 'http.client')?.span_id;
329285

330286
expect(traceId).toEqual(expect.any(String));
331287
expect(spanId).toEqual(expect.any(String));
@@ -335,30 +291,20 @@ test('Does not propagate outgoing http requests not covered by tracePropagationT
335291
expect(data.headers?.baggage).toBeUndefined();
336292
});
337293

338-
test('Propagates trace for outgoing external fetch requests', async ({
339-
baseURL,
340-
}) => {
341-
const inboundTransactionPromise = waitForTransaction(
342-
'node-nestjs-app',
343-
(transactionEvent) => {
344-
return (
345-
transactionEvent?.contexts?.trace?.op === 'http.server' &&
346-
transactionEvent.contexts?.trace?.data?.['http.target'] ===
347-
`/test-outgoing-fetch-external-allowed`
348-
);
349-
},
350-
);
294+
test('Propagates trace for outgoing external fetch requests', async ({ baseURL }) => {
295+
const inboundTransactionPromise = waitForTransaction('node-nestjs-app', transactionEvent => {
296+
return (
297+
transactionEvent?.contexts?.trace?.op === 'http.server' &&
298+
transactionEvent.contexts?.trace?.data?.['http.target'] === `/test-outgoing-fetch-external-allowed`
299+
);
300+
});
351301

352-
const { data } = await axios.get(
353-
`${baseURL}/test-outgoing-fetch-external-allowed`,
354-
);
302+
const { data } = await axios.get(`${baseURL}/test-outgoing-fetch-external-allowed`);
355303

356304
const inboundTransaction = await inboundTransactionPromise;
357305

358306
const traceId = inboundTransaction?.contexts?.trace?.trace_id;
359-
const spanId = inboundTransaction?.spans?.find(
360-
(span) => span.op === 'http.client',
361-
)?.span_id;
307+
const spanId = inboundTransaction?.spans?.find(span => span.op === 'http.client')?.span_id;
362308

363309
expect(traceId).toEqual(expect.any(String));
364310
expect(spanId).toEqual(expect.any(String));
@@ -381,30 +327,20 @@ test('Propagates trace for outgoing external fetch requests', async ({
381327
);
382328
});
383329

384-
test('Does not propagate outgoing fetch requests not covered by tracePropagationTargets', async ({
385-
baseURL,
386-
}) => {
387-
const inboundTransactionPromise = waitForTransaction(
388-
'node-nestjs-app',
389-
(transactionEvent) => {
390-
return (
391-
transactionEvent?.contexts?.trace?.op === 'http.server' &&
392-
transactionEvent.contexts?.trace?.data?.['http.target'] ===
393-
`/test-outgoing-fetch-external-disallowed`
394-
);
395-
},
396-
);
330+
test('Does not propagate outgoing fetch requests not covered by tracePropagationTargets', async ({ baseURL }) => {
331+
const inboundTransactionPromise = waitForTransaction('node-nestjs-app', transactionEvent => {
332+
return (
333+
transactionEvent?.contexts?.trace?.op === 'http.server' &&
334+
transactionEvent.contexts?.trace?.data?.['http.target'] === `/test-outgoing-fetch-external-disallowed`
335+
);
336+
});
397337

398-
const { data } = await axios.get(
399-
`${baseURL}/test-outgoing-fetch-external-disallowed`,
400-
);
338+
const { data } = await axios.get(`${baseURL}/test-outgoing-fetch-external-disallowed`);
401339

402340
const inboundTransaction = await inboundTransactionPromise;
403341

404342
const traceId = inboundTransaction?.contexts?.trace?.trace_id;
405-
const spanId = inboundTransaction?.spans?.find(
406-
(span) => span.op === 'http.client',
407-
)?.span_id;
343+
const spanId = inboundTransaction?.spans?.find(span => span.op === 'http.client')?.span_id;
408344

409345
expect(traceId).toEqual(expect.any(String));
410346
expect(spanId).toEqual(expect.any(String));

dev-packages/e2e-tests/test-applications/node-nestjs-app/tests/transactions.test.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@ const sentryTestProject = process.env.E2E_TEST_SENTRY_TEST_PROJECT;
88
const EVENT_POLLING_TIMEOUT = 90_000;
99

1010
test('Sends an API route transaction', async ({ baseURL }) => {
11-
const pageloadTransactionEventPromise = waitForTransaction(
12-
'node-nestjs-app',
13-
(transactionEvent) => {
14-
return (
15-
transactionEvent?.contexts?.trace?.op === 'http.server' &&
16-
transactionEvent?.transaction === 'GET /test-transaction'
17-
);
18-
},
19-
);
11+
const pageloadTransactionEventPromise = waitForTransaction('node-nestjs-app', transactionEvent => {
12+
return (
13+
transactionEvent?.contexts?.trace?.op === 'http.server' &&
14+
transactionEvent?.transaction === 'GET /test-transaction'
15+
);
16+
});
2017

2118
await axios.get(`${baseURL}/test-transaction`);
2219

0 commit comments

Comments
 (0)