@@ -108,13 +108,20 @@ export class Http implements Integration {
108108 return ;
109109 }
110110
111- // TODO (v8): `tracePropagationTargets` and `shouldCreateSpanForRequest` will be removed from clientOptions
112- // and we will no longer have to do this optional merge, we can just pass `this._tracing` directly.
113- const tracingOptions = this . _tracing ? { ...clientOptions , ...this . _tracing } : undefined ;
111+ const shouldCreateSpanForRequest =
112+ // eslint-disable-next-line deprecation/deprecation
113+ this . _tracing ?. shouldCreateSpanForRequest || clientOptions ?. shouldCreateSpanForRequest ;
114+ // eslint-disable-next-line deprecation/deprecation
115+ const tracePropagationTargets = clientOptions ?. tracePropagationTargets || this . _tracing ?. tracePropagationTargets ;
114116
115117 // eslint-disable-next-line @typescript-eslint/no-var-requires
116118 const httpModule = require ( 'http' ) ;
117- const wrappedHttpHandlerMaker = _createWrappedRequestMethodFactory ( this . _breadcrumbs , tracingOptions , httpModule ) ;
119+ const wrappedHttpHandlerMaker = _createWrappedRequestMethodFactory (
120+ httpModule ,
121+ this . _breadcrumbs ,
122+ shouldCreateSpanForRequest ,
123+ tracePropagationTargets ,
124+ ) ;
118125 fill ( httpModule , 'get' , wrappedHttpHandlerMaker ) ;
119126 fill ( httpModule , 'request' , wrappedHttpHandlerMaker ) ;
120127
@@ -125,9 +132,10 @@ export class Http implements Integration {
125132 // eslint-disable-next-line @typescript-eslint/no-var-requires
126133 const httpsModule = require ( 'https' ) ;
127134 const wrappedHttpsHandlerMaker = _createWrappedRequestMethodFactory (
128- this . _breadcrumbs ,
129- tracingOptions ,
130135 httpsModule ,
136+ this . _breadcrumbs ,
137+ shouldCreateSpanForRequest ,
138+ tracePropagationTargets ,
131139 ) ;
132140 fill ( httpsModule , 'get' , wrappedHttpsHandlerMaker ) ;
133141 fill ( httpsModule , 'request' , wrappedHttpsHandlerMaker ) ;
@@ -150,16 +158,17 @@ type WrappedRequestMethodFactory = (original: OriginalRequestMethod) => WrappedR
150158 * @returns A function which accepts the exiting handler and returns a wrapped handler
151159 */
152160function _createWrappedRequestMethodFactory (
153- breadcrumbsEnabled : boolean ,
154- tracingOptions : TracingOptions | undefined ,
155161 httpModule : typeof http | typeof https ,
162+ breadcrumbsEnabled : boolean ,
163+ shouldCreateSpanForRequest : ( ( url : string ) => boolean ) | undefined ,
164+ tracePropagationTargets : TracePropagationTargets | undefined ,
156165) : WrappedRequestMethodFactory {
157166 // We're caching results so we don't have to recompute regexp every time we create a request.
158167 const createSpanUrlMap = new LRUMap < string , boolean > ( 100 ) ;
159168 const headersUrlMap = new LRUMap < string , boolean > ( 100 ) ;
160169
161170 const shouldCreateSpan = ( url : string ) : boolean => {
162- if ( tracingOptions ?. shouldCreateSpanForRequest === undefined ) {
171+ if ( shouldCreateSpanForRequest === undefined ) {
163172 return true ;
164173 }
165174
@@ -168,14 +177,13 @@ function _createWrappedRequestMethodFactory(
168177 return cachedDecision ;
169178 }
170179
171- const decision = tracingOptions . shouldCreateSpanForRequest ( url ) ;
180+ const decision = shouldCreateSpanForRequest ( url ) ;
172181 createSpanUrlMap . set ( url , decision ) ;
173182 return decision ;
174183 } ;
175184
176185 const shouldAttachTraceData = ( url : string ) : boolean => {
177- // eslint-disable-next-line deprecation/deprecation
178- if ( tracingOptions ?. tracePropagationTargets === undefined ) {
186+ if ( tracePropagationTargets === undefined ) {
179187 return true ;
180188 }
181189
@@ -184,8 +192,7 @@ function _createWrappedRequestMethodFactory(
184192 return cachedDecision ;
185193 }
186194
187- // eslint-disable-next-line deprecation/deprecation
188- const decision = stringMatchesSomePattern ( url , tracingOptions . tracePropagationTargets ) ;
195+ const decision = stringMatchesSomePattern ( url , tracePropagationTargets ) ;
189196 headersUrlMap . set ( url , decision ) ;
190197 return decision ;
191198 } ;
0 commit comments