|
1 | 1 | import { expect, test } from '@playwright/test'; |
2 | 2 | import { waitForTransaction } from '@sentry-internal/test-utils'; |
3 | 3 |
|
| 4 | +const useSentryTracerProvider = process.env.E2E_USE_SENTRY_TRACER_PROVIDER === '1'; |
| 5 | + |
4 | 6 | test('Sends an API route transaction', async ({ baseURL }) => { |
5 | 7 | const pageloadTransactionEventPromise = waitForTransaction('node-connect', transactionEvent => { |
6 | 8 | return ( |
@@ -54,41 +56,47 @@ test('Sends an API route transaction', async ({ baseURL }) => { |
54 | 56 | origin: 'auto.http.otel.http', |
55 | 57 | }); |
56 | 58 |
|
| 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 | + |
57 | 92 | expect(transactionEvent).toEqual( |
58 | 93 | 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], |
92 | 100 | transaction: 'GET /test-transaction', |
93 | 101 | type: 'transaction', |
94 | 102 | transaction_info: { |
|
0 commit comments