@@ -108,13 +108,20 @@ export class Http implements Integration {
108
108
return ;
109
109
}
110
110
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 ;
114
116
115
117
// eslint-disable-next-line @typescript-eslint/no-var-requires
116
118
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
+ ) ;
118
125
fill ( httpModule , 'get' , wrappedHttpHandlerMaker ) ;
119
126
fill ( httpModule , 'request' , wrappedHttpHandlerMaker ) ;
120
127
@@ -125,9 +132,10 @@ export class Http implements Integration {
125
132
// eslint-disable-next-line @typescript-eslint/no-var-requires
126
133
const httpsModule = require ( 'https' ) ;
127
134
const wrappedHttpsHandlerMaker = _createWrappedRequestMethodFactory (
128
- this . _breadcrumbs ,
129
- tracingOptions ,
130
135
httpsModule ,
136
+ this . _breadcrumbs ,
137
+ shouldCreateSpanForRequest ,
138
+ tracePropagationTargets ,
131
139
) ;
132
140
fill ( httpsModule , 'get' , wrappedHttpsHandlerMaker ) ;
133
141
fill ( httpsModule , 'request' , wrappedHttpsHandlerMaker ) ;
@@ -150,16 +158,17 @@ type WrappedRequestMethodFactory = (original: OriginalRequestMethod) => WrappedR
150
158
* @returns A function which accepts the exiting handler and returns a wrapped handler
151
159
*/
152
160
function _createWrappedRequestMethodFactory (
153
- breadcrumbsEnabled : boolean ,
154
- tracingOptions : TracingOptions | undefined ,
155
161
httpModule : typeof http | typeof https ,
162
+ breadcrumbsEnabled : boolean ,
163
+ shouldCreateSpanForRequest : ( ( url : string ) => boolean ) | undefined ,
164
+ tracePropagationTargets : TracePropagationTargets | undefined ,
156
165
) : WrappedRequestMethodFactory {
157
166
// We're caching results so we don't have to recompute regexp every time we create a request.
158
167
const createSpanUrlMap = new LRUMap < string , boolean > ( 100 ) ;
159
168
const headersUrlMap = new LRUMap < string , boolean > ( 100 ) ;
160
169
161
170
const shouldCreateSpan = ( url : string ) : boolean => {
162
- if ( tracingOptions ?. shouldCreateSpanForRequest === undefined ) {
171
+ if ( shouldCreateSpanForRequest === undefined ) {
163
172
return true ;
164
173
}
165
174
@@ -168,14 +177,13 @@ function _createWrappedRequestMethodFactory(
168
177
return cachedDecision ;
169
178
}
170
179
171
- const decision = tracingOptions . shouldCreateSpanForRequest ( url ) ;
180
+ const decision = shouldCreateSpanForRequest ( url ) ;
172
181
createSpanUrlMap . set ( url , decision ) ;
173
182
return decision ;
174
183
} ;
175
184
176
185
const shouldAttachTraceData = ( url : string ) : boolean => {
177
- // eslint-disable-next-line deprecation/deprecation
178
- if ( tracingOptions ?. tracePropagationTargets === undefined ) {
186
+ if ( tracePropagationTargets === undefined ) {
179
187
return true ;
180
188
}
181
189
@@ -184,8 +192,7 @@ function _createWrappedRequestMethodFactory(
184
192
return cachedDecision ;
185
193
}
186
194
187
- // eslint-disable-next-line deprecation/deprecation
188
- const decision = stringMatchesSomePattern ( url , tracingOptions . tracePropagationTargets ) ;
195
+ const decision = stringMatchesSomePattern ( url , tracePropagationTargets ) ;
189
196
headersUrlMap . set ( url , decision ) ;
190
197
return decision ;
191
198
} ;
0 commit comments