|
| 1 | +import { expect } from '@playwright/test'; |
| 2 | + |
| 3 | +import type { TransactionEvent } from '@sentry/types'; |
| 4 | +import { sentryTest } from '../../../../utils/fixtures'; |
| 5 | +import { envelopeRequestParser, shouldSkipTracingTest, waitForTransactionRequest } from '../../../../utils/helpers'; |
| 6 | + |
| 7 | +sentryTest( |
| 8 | + 'should send manually started parallel root spans outside of root context', |
| 9 | + async ({ getLocalTestUrl, page }) => { |
| 10 | + if (shouldSkipTracingTest()) { |
| 11 | + sentryTest.skip(); |
| 12 | + } |
| 13 | + |
| 14 | + const url = await getLocalTestUrl({ testDir: __dirname }); |
| 15 | + |
| 16 | + const transaction1ReqPromise = waitForTransactionRequest(page, event => event.transaction === 'test_span_1'); |
| 17 | + const transaction2ReqPromise = waitForTransactionRequest(page, event => event.transaction === 'test_span_2'); |
| 18 | + |
| 19 | + await page.goto(url); |
| 20 | + |
| 21 | + const [transaction1Req, transaction2Req] = await Promise.all([transaction1ReqPromise, transaction2ReqPromise]); |
| 22 | + |
| 23 | + const transaction1 = envelopeRequestParser<TransactionEvent>(transaction1Req); |
| 24 | + const transaction2 = envelopeRequestParser<TransactionEvent>(transaction2Req); |
| 25 | + |
| 26 | + expect(transaction1).toBeDefined(); |
| 27 | + expect(transaction2).toBeDefined(); |
| 28 | + |
| 29 | + const trace1Id = transaction1.contexts?.trace?.trace_id; |
| 30 | + const trace2Id = transaction2.contexts?.trace?.trace_id; |
| 31 | + |
| 32 | + expect(trace1Id).toBeDefined(); |
| 33 | + expect(trace2Id).toBeDefined(); |
| 34 | + |
| 35 | + // We use the same traceID from the root propagation context here |
| 36 | + expect(trace1Id).toBe(trace2Id); |
| 37 | + |
| 38 | + expect(transaction1.contexts?.trace?.parent_span_id).toBeUndefined(); |
| 39 | + expect(transaction2.contexts?.trace?.parent_span_id).toBeUndefined(); |
| 40 | + }, |
| 41 | +); |
0 commit comments