Skip to content

Commit 1fff7a3

Browse files
committed
add integration tests
1 parent bc19a66 commit 1fff7a3

4 files changed

Lines changed: 59 additions & 2 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
window.Sentry = Sentry;
4+
5+
Sentry.init({
6+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
7+
integrations: [Sentry.spanStreamingIntegration()],
8+
ignoreSpans: [{ attributes: { 'http.status_code': 200 } }],
9+
tracesSampleRate: 1,
10+
debug: true,
11+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// This segment span matches ignoreSpans via attributes — segment + child should be dropped
2+
Sentry.startSpan({ name: 'health-check', attributes: { 'http.status_code': 200 } }, () => {
3+
Sentry.startSpan({ name: 'child-of-ignored' }, () => {});
4+
});
5+
6+
setTimeout(() => {
7+
// This segment span does NOT match — segment + child should be sent
8+
Sentry.startSpan({ name: 'normal-segment', attributes: { 'http.status_code': 500 } }, () => {
9+
Sentry.startSpan({ name: 'child-span' }, () => {});
10+
});
11+
}, 1000);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { expect } from '@playwright/test';
2+
import type { ClientReport } from '@sentry/core';
3+
import { sentryTest } from '../../../../utils/fixtures';
4+
import {
5+
envelopeRequestParser,
6+
hidePage,
7+
shouldSkipTracingTest,
8+
waitForClientReportRequest,
9+
} from '../../../../utils/helpers';
10+
import { observeStreamedSpan, waitForStreamedSpans } from '../../../../utils/spanUtils';
11+
12+
sentryTest('attribute-matching ignoreSpans drops the trace', async ({ getLocalTestUrl, page }) => {
13+
sentryTest.skip(shouldSkipTracingTest());
14+
15+
const url = await getLocalTestUrl({ testDir: __dirname });
16+
17+
observeStreamedSpan(page, span => {
18+
if (span.name === 'health-check' || span.name === 'child-of-ignored') {
19+
throw new Error('Ignored span found');
20+
}
21+
return false;
22+
});
23+
24+
const spansPromise = waitForStreamedSpans(page, spans => !!spans?.find(s => s.name === 'normal-segment'));
25+
const clientReportPromise = waitForClientReportRequest(page);
26+
27+
await page.goto(url);
28+
29+
expect((await spansPromise)?.length).toBe(2);
30+
31+
await hidePage(page);
32+
33+
const clientReport = envelopeRequestParser<ClientReport>(await clientReportPromise);
34+
expect(clientReport.discarded_events).toEqual([{ category: 'span', quantity: 2, reason: 'ignored' }]);
35+
});

dev-packages/browser-integration-tests/suites/tracing/ignoreSpans-streamed/segment/subject.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// This segment span matches ignoreSpans — should NOT produce a transaction
1+
// This segment span matches ignoreSpans — segment + child should be dropped
22
Sentry.startSpan({ name: 'ignore-segment' }, () => {
33
Sentry.startSpan({ name: 'child-of-ignored-segment' }, () => {});
44
});
55

66
setTimeout(() => {
7-
// This segment span does NOT match — should produce a transaction
7+
// This segment span does NOT match — segment + child should be sent
88
Sentry.startSpan({ name: 'normal-segment' }, () => {
99
Sentry.startSpan({ name: 'child-span' }, () => {});
1010
});

0 commit comments

Comments
 (0)