@@ -300,6 +300,13 @@ interface AddPerformanceEntriesOptions {
300300 * sent as a standalone span instead.
301301 */
302302 recordClsOnPageloadSpan : boolean ;
303+
304+ /**
305+ * Resource spans matching strings in the array will not be emitted.
306+ *
307+ * Default: []
308+ */
309+ ignoreResourceSpans : Array < string > ;
303310}
304311
305312/** Add performance related spans to a transaction */
@@ -355,7 +362,7 @@ export function addPerformanceEntries(span: Span, options: AddPerformanceEntries
355362 break ;
356363 }
357364 case 'resource' : {
358- _addResourceSpans ( span , entry as PerformanceResourceTiming , entry . name , startTime , duration , timeOrigin ) ;
365+ _addResourceSpans ( span , entry as PerformanceResourceTiming , entry . name , startTime , duration , timeOrigin , options . ignoreResourceSpans ) ;
359366 break ;
360367 }
361368 // Ignore other entry types.
@@ -568,13 +575,19 @@ export function _addResourceSpans(
568575 startTime : number ,
569576 duration : number ,
570577 timeOrigin : number ,
578+ ignoreResourceSpans ?: Array < string >
571579) : void {
572580 // we already instrument based on fetch and xhr, so we don't need to
573581 // duplicate spans here.
574582 if ( entry . initiatorType === 'xmlhttprequest' || entry . initiatorType === 'fetch' ) {
575583 return ;
576584 }
577585
586+ const op = entry . initiatorType ? `resource.${ entry . initiatorType } ` : 'resource.other' ;
587+ if ( ignoreResourceSpans ?. includes ( op ) ) {
588+ return ;
589+ }
590+
578591 const parsedUrl = parseUrl ( resourceUrl ) ;
579592
580593 const attributes : SpanAttributes = {
@@ -616,7 +629,7 @@ export function _addResourceSpans(
616629
617630 startAndEndSpan ( span , startTimestamp , endTimestamp , {
618631 name : resourceUrl . replace ( WINDOW . location . origin , '' ) ,
619- op : entry . initiatorType ? `resource. ${ entry . initiatorType } ` : 'resource.other' ,
632+ op,
620633 attributes,
621634 } ) ;
622635}
0 commit comments