|
| 1 | +import { expect } from '@playwright/test'; |
| 2 | +import { sentryTest } from '../../../../utils/fixtures'; |
| 3 | +import { |
| 4 | + envelopeRequestParser, |
| 5 | + hidePage, |
| 6 | + shouldSkipTracingTest, |
| 7 | + testingCdnBundle, |
| 8 | + waitForClientReportRequest, |
| 9 | +} from '../../../../utils/helpers'; |
| 10 | +import { waitForStreamedSpans } from '../../../../utils/spanUtils'; |
| 11 | +import type { ClientReport } from '@sentry/core'; |
| 12 | + |
| 13 | +sentryTest('ignored child spans are dropped and their children are reparented', async ({ getLocalTestUrl, page }) => { |
| 14 | + sentryTest.skip(shouldSkipTracingTest() || testingCdnBundle()); |
| 15 | + |
| 16 | + const spansPromise = waitForStreamedSpans(page, spans => !!spans?.find(s => s.name === 'parent-span')); |
| 17 | + |
| 18 | + const clientReportPromise = waitForClientReportRequest(page); |
| 19 | + |
| 20 | + const url = await getLocalTestUrl({ testDir: __dirname }); |
| 21 | + await page.goto(url); |
| 22 | + |
| 23 | + const spans = await spansPromise; |
| 24 | + |
| 25 | + await hidePage(page); |
| 26 | + |
| 27 | + const clientReport = envelopeRequestParser<ClientReport>(await clientReportPromise); |
| 28 | + |
| 29 | + const segmentSpanId = spans.find(s => s.name === 'parent-span')?.span_id; |
| 30 | + |
| 31 | + expect(spans.length).toBe(6); |
| 32 | + |
| 33 | + expect(spans.some(s => s.name === 'keep-me')).toBe(true); |
| 34 | + expect(spans.some(s => s.name === 'another-keeper')).toBe(true); |
| 35 | + |
| 36 | + expect(spans.some(s => s.name?.includes('ignore'))).toBe(false); |
| 37 | + |
| 38 | + const greatGrandChild1 = spans.find(s => s.name === 'great-grandchild-1'); |
| 39 | + const grandchild2 = spans.find(s => s.name === 'grandchild-2'); |
| 40 | + const greatGreatGreatGrandChild1 = spans.find(s => s.name === 'great-great-great-grandchild-1'); |
| 41 | + |
| 42 | + expect(greatGrandChild1).toBeDefined(); |
| 43 | + expect(grandchild2).toBeDefined(); |
| 44 | + expect(greatGreatGreatGrandChild1).toBeDefined(); |
| 45 | + |
| 46 | + expect(greatGrandChild1?.parent_span_id).toBe(segmentSpanId); |
| 47 | + expect(grandchild2?.parent_span_id).toBe(segmentSpanId); |
| 48 | + expect(greatGreatGreatGrandChild1?.parent_span_id).toBe(greatGrandChild1?.span_id); |
| 49 | + |
| 50 | + expect(spans.every(s => s.name === 'parent-span' || !s.is_segment)).toBe(true); |
| 51 | + |
| 52 | + expect(clientReport.discarded_events).toEqual([ |
| 53 | + { |
| 54 | + category: 'span', |
| 55 | + quantity: 5, // 5 ignored child spans |
| 56 | + reason: 'ignored', |
| 57 | + }, |
| 58 | + ]); |
| 59 | +}); |
0 commit comments