@@ -205,6 +205,14 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
205205 // eslint-disable-next-line @typescript-eslint/no-this-alias
206206 const instrumentation = this ;
207207
208+ const _breadcrumbs = instrumentation . getConfig ( ) . breadcrumbs ;
209+ const breadcrumbsEnabled = typeof _breadcrumbs === 'undefined' ? true : _breadcrumbs ;
210+
211+ // Skip work here when breadcrumbs are disabled
212+ if ( ! breadcrumbsEnabled ) {
213+ return original => original ;
214+ }
215+
208216 return ( original : ( ...args : unknown [ ] ) => http . ClientRequest ) : ( ( ...args : unknown [ ] ) => http . ClientRequest ) => {
209217 return function outgoingRequest ( this : unknown , ...args : unknown [ ] ) : http . ClientRequest {
210218 instrumentation . _diag . debug ( 'http instrumentation for outgoing requests' ) ;
@@ -227,16 +235,13 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
227235 const request = original . apply ( this , args ) as ReturnType < typeof http . request > ;
228236
229237 request . prependListener ( 'response' , ( response : http . IncomingMessage ) => {
230- const _breadcrumbs = instrumentation . getConfig ( ) . breadcrumbs ;
231- const breadCrumbsEnabled = typeof _breadcrumbs === 'undefined' ? true : _breadcrumbs ;
232-
233238 const _ignoreOutgoingRequests = instrumentation . getConfig ( ) . ignoreOutgoingRequests ;
234239 const shouldCreateBreadcrumb =
235240 typeof _ignoreOutgoingRequests === 'function'
236241 ? ! _ignoreOutgoingRequests ( getRequestUrl ( request ) , optionsParsed )
237242 : true ;
238243
239- if ( breadCrumbsEnabled && shouldCreateBreadcrumb ) {
244+ if ( shouldCreateBreadcrumb ) {
240245 addRequestBreadcrumb ( request , response ) ;
241246 }
242247 } ) ;
0 commit comments