Skip to content

Commit 6759aa8

Browse files
committed
Fix node-connect tests
1 parent 324c8e8 commit 6759aa8

1 file changed

Lines changed: 41 additions & 33 deletions

File tree

‎dev-packages/e2e-tests/test-applications/node-connect/tests/transactions.test.ts‎

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { expect, test } from '@playwright/test';
22
import { waitForTransaction } from '@sentry-internal/test-utils';
33

4+
const useSentryTracerProvider = process.env.E2E_USE_SENTRY_TRACER_PROVIDER === '1';
5+
46
test('Sends an API route transaction', async ({ baseURL }) => {
57
const pageloadTransactionEventPromise = waitForTransaction('node-connect', transactionEvent => {
68
return (
@@ -54,41 +56,47 @@ test('Sends an API route transaction', async ({ baseURL }) => {
5456
origin: 'auto.http.otel.http',
5557
});
5658

59+
const manualSpanExpectation = {
60+
data: {
61+
'sentry.origin': 'manual',
62+
},
63+
description: 'test-span',
64+
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
65+
span_id: expect.stringMatching(/[a-f0-9]{16}/),
66+
start_timestamp: expect.any(Number),
67+
status: 'ok',
68+
timestamp: expect.any(Number),
69+
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
70+
origin: 'manual',
71+
};
72+
73+
const connectSpanExpectation = {
74+
data: {
75+
'sentry.origin': 'auto.http.otel.connect',
76+
'sentry.op': 'request_handler.connect',
77+
'http.route': '/test-transaction',
78+
'connect.type': 'request_handler',
79+
'connect.name': '/test-transaction',
80+
},
81+
op: 'request_handler.connect',
82+
description: '/test-transaction',
83+
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
84+
span_id: expect.stringMatching(/[a-f0-9]{16}/),
85+
start_timestamp: expect.any(Number),
86+
status: 'ok',
87+
timestamp: expect.any(Number),
88+
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
89+
origin: 'auto.http.otel.connect',
90+
};
91+
5792
expect(transactionEvent).toEqual(
5893
expect.objectContaining({
59-
spans: [
60-
{
61-
data: {
62-
'sentry.origin': 'manual',
63-
},
64-
description: 'test-span',
65-
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
66-
span_id: expect.stringMatching(/[a-f0-9]{16}/),
67-
start_timestamp: expect.any(Number),
68-
status: 'ok',
69-
timestamp: expect.any(Number),
70-
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
71-
origin: 'manual',
72-
},
73-
{
74-
data: {
75-
'sentry.origin': 'auto.http.otel.connect',
76-
'sentry.op': 'request_handler.connect',
77-
'http.route': '/test-transaction',
78-
'connect.type': 'request_handler',
79-
'connect.name': '/test-transaction',
80-
},
81-
op: 'request_handler.connect',
82-
description: '/test-transaction',
83-
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
84-
span_id: expect.stringMatching(/[a-f0-9]{16}/),
85-
start_timestamp: expect.any(Number),
86-
status: 'ok',
87-
timestamp: expect.any(Number),
88-
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
89-
origin: 'auto.http.otel.connect',
90-
},
91-
],
94+
// The SentryTracerProvider serializes native child spans in start/tree order, so the
95+
// Connect handler span appears before the manual span created inside it. The legacy
96+
// OTel exporter path emits them in finish order, where the manual span comes first.
97+
spans: useSentryTracerProvider
98+
? [connectSpanExpectation, manualSpanExpectation]
99+
: [manualSpanExpectation, connectSpanExpectation],
92100
transaction: 'GET /test-transaction',
93101
type: 'transaction',
94102
transaction_info: {

0 commit comments

Comments
 (0)