File tree Expand file tree Collapse file tree
dev-packages/browser-integration-tests/suites/tracing/ignoreSpans-streamed Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ } ) ;
Original file line number Diff line number Diff line change 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 ) ;
Original file line number Diff line number Diff line change 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+ } ) ;
Original file line number Diff line number Diff line change 1- // This segment span matches ignoreSpans — should NOT produce a transaction
1+ // This segment span matches ignoreSpans — segment + child should be dropped
22Sentry . startSpan ( { name : 'ignore-segment' } , ( ) => {
33 Sentry . startSpan ( { name : 'child-of-ignored-segment' } , ( ) => { } ) ;
44} ) ;
55
66setTimeout ( ( ) => {
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 } ) ;
You can’t perform that action at this time.
0 commit comments