@@ -10,6 +10,7 @@ import {
1010} from '@sentry/utils' ;
1111import type * as http from 'http' ;
1212import type * as https from 'https' ;
13+ import { LRUMap } from 'lru_map' ;
1314
1415import type { NodeClient } from '../client' ;
1516import type { RequestMethod , RequestMethodArgs } from './utils/http' ;
@@ -138,21 +139,22 @@ function _createWrappedRequestMethodFactory(
138139 tracingOptions : TracingOptions | undefined ,
139140) : WrappedRequestMethodFactory {
140141 // We're caching results so we don't have to recompute regexp every time we create a request.
141- const createSpanUrlMap : Record < string , boolean > = { } ;
142+ const createSpanUrlMap = new LRUMap < string , boolean > ( 100 ) ;
142143 const headersUrlMap : Record < string , boolean > = { } ;
143144
144145 const shouldCreateSpan = ( url : string ) : boolean => {
145146 if ( tracingOptions ?. shouldCreateSpanForRequest === undefined ) {
146147 return true ;
147148 }
148149
149- if ( createSpanUrlMap [ url ] ) {
150- return createSpanUrlMap [ url ] ;
150+ const cachedDecision = createSpanUrlMap . get ( url ) ;
151+ if ( cachedDecision !== undefined ) {
152+ return cachedDecision ;
151153 }
152154
153- createSpanUrlMap [ url ] = tracingOptions . shouldCreateSpanForRequest ( url ) ;
154-
155- return createSpanUrlMap [ url ] ;
155+ const decision = tracingOptions . shouldCreateSpanForRequest ( url ) ;
156+ createSpanUrlMap . set ( url , decision ) ;
157+ return decision ;
156158 } ;
157159
158160 const shouldAttachTraceData = ( url : string ) : boolean => {
0 commit comments