@@ -12,6 +12,7 @@ import type { AggregationCounts, Client, SanitizedRequestData, Scope } from '@se
12
12
import {
13
13
addBreadcrumb ,
14
14
addNonEnumerableProperty ,
15
+ debug ,
15
16
generateSpanId ,
16
17
getBreadcrumbLogLevelFromHttpStatusCode ,
17
18
getClient ,
@@ -21,7 +22,6 @@ import {
21
22
getTraceData ,
22
23
httpRequestToRequestData ,
23
24
isError ,
24
- logger ,
25
25
LRUMap ,
26
26
parseUrl ,
27
27
SDK_VERSION ,
@@ -219,7 +219,7 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
219
219
* It has access to the final request and response objects.
220
220
*/
221
221
private _onOutgoingRequestFinish ( request : http . ClientRequest , response ?: http . IncomingMessage ) : void {
222
- DEBUG_BUILD && logger . log ( INSTRUMENTATION_NAME , 'Handling finished outgoing request' ) ;
222
+ DEBUG_BUILD && debug . log ( INSTRUMENTATION_NAME , 'Handling finished outgoing request' ) ;
223
223
224
224
const _breadcrumbs = this . getConfig ( ) . breadcrumbs ;
225
225
const breadCrumbsEnabled = typeof _breadcrumbs === 'undefined' ? true : _breadcrumbs ;
@@ -266,10 +266,10 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
266
266
if ( sentryTrace && ! request . getHeader ( 'sentry-trace' ) ) {
267
267
try {
268
268
request . setHeader ( 'sentry-trace' , sentryTrace ) ;
269
- DEBUG_BUILD && logger . log ( INSTRUMENTATION_NAME , 'Added sentry-trace header to outgoing request' ) ;
269
+ DEBUG_BUILD && debug . log ( INSTRUMENTATION_NAME , 'Added sentry-trace header to outgoing request' ) ;
270
270
} catch ( error ) {
271
271
DEBUG_BUILD &&
272
- logger . error (
272
+ debug . error (
273
273
INSTRUMENTATION_NAME ,
274
274
'Failed to add sentry-trace header to outgoing request:' ,
275
275
isError ( error ) ? error . message : 'Unknown error' ,
@@ -283,10 +283,10 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
283
283
if ( newBaggage ) {
284
284
try {
285
285
request . setHeader ( 'baggage' , newBaggage ) ;
286
- DEBUG_BUILD && logger . log ( INSTRUMENTATION_NAME , 'Added baggage header to outgoing request' ) ;
286
+ DEBUG_BUILD && debug . log ( INSTRUMENTATION_NAME , 'Added baggage header to outgoing request' ) ;
287
287
} catch ( error ) {
288
288
DEBUG_BUILD &&
289
- logger . error (
289
+ debug . error (
290
290
INSTRUMENTATION_NAME ,
291
291
'Failed to add baggage header to outgoing request:' ,
292
292
isError ( error ) ? error . message : 'Unknown error' ,
@@ -309,7 +309,7 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
309
309
return ;
310
310
}
311
311
312
- DEBUG_BUILD && logger . log ( INSTRUMENTATION_NAME , 'Patching server.emit' ) ;
312
+ DEBUG_BUILD && debug . log ( INSTRUMENTATION_NAME , 'Patching server.emit' ) ;
313
313
314
314
// eslint-disable-next-line @typescript-eslint/no-this-alias
315
315
const instrumentation = this ;
@@ -322,7 +322,7 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
322
322
return target . apply ( thisArg , args ) ;
323
323
}
324
324
325
- DEBUG_BUILD && logger . log ( INSTRUMENTATION_NAME , 'Handling incoming request' ) ;
325
+ DEBUG_BUILD && debug . log ( INSTRUMENTATION_NAME , 'Handling incoming request' ) ;
326
326
327
327
const isolationScope = getIsolationScope ( ) . clone ( ) ;
328
328
const request = args [ 1 ] as http . IncomingMessage ;
@@ -467,7 +467,7 @@ function patchRequestToCaptureBody(
467
467
let bodyByteLength = 0 ;
468
468
const chunks : Buffer [ ] = [ ] ;
469
469
470
- DEBUG_BUILD && logger . log ( INSTRUMENTATION_NAME , 'Patching request.on' ) ;
470
+ DEBUG_BUILD && debug . log ( INSTRUMENTATION_NAME , 'Patching request.on' ) ;
471
471
472
472
/**
473
473
* We need to keep track of the original callbacks, in order to be able to remove listeners again.
@@ -491,7 +491,7 @@ function patchRequestToCaptureBody(
491
491
492
492
if ( event === 'data' ) {
493
493
DEBUG_BUILD &&
494
- logger . log ( INSTRUMENTATION_NAME , `Handling request.on("data") with maximum body size of ${ maxBodySize } b` ) ;
494
+ debug . log ( INSTRUMENTATION_NAME , `Handling request.on("data") with maximum body size of ${ maxBodySize } b` ) ;
495
495
496
496
const callback = new Proxy ( listener , {
497
497
apply : ( target , thisArg , args : Parameters < typeof listener > ) => {
@@ -503,13 +503,13 @@ function patchRequestToCaptureBody(
503
503
chunks . push ( bufferifiedChunk ) ;
504
504
bodyByteLength += bufferifiedChunk . byteLength ;
505
505
} else if ( DEBUG_BUILD ) {
506
- logger . log (
506
+ debug . log (
507
507
INSTRUMENTATION_NAME ,
508
508
`Dropping request body chunk because maximum body length of ${ maxBodySize } b is exceeded.` ,
509
509
) ;
510
510
}
511
511
} catch ( err ) {
512
- DEBUG_BUILD && logger . error ( INSTRUMENTATION_NAME , 'Encountered error while storing body chunk.' ) ;
512
+ DEBUG_BUILD && debug . error ( INSTRUMENTATION_NAME , 'Encountered error while storing body chunk.' ) ;
513
513
}
514
514
515
515
return Reflect . apply ( target , thisArg , args ) ;
@@ -561,13 +561,13 @@ function patchRequestToCaptureBody(
561
561
}
562
562
} catch ( error ) {
563
563
if ( DEBUG_BUILD ) {
564
- logger . error ( INSTRUMENTATION_NAME , 'Error building captured request body' , error ) ;
564
+ debug . error ( INSTRUMENTATION_NAME , 'Error building captured request body' , error ) ;
565
565
}
566
566
}
567
567
} ) ;
568
568
} catch ( error ) {
569
569
if ( DEBUG_BUILD ) {
570
- logger . error ( INSTRUMENTATION_NAME , 'Error patching request to capture body' , error ) ;
570
+ debug . error ( INSTRUMENTATION_NAME , 'Error patching request to capture body' , error ) ;
571
571
}
572
572
}
573
573
}
@@ -611,7 +611,7 @@ export function recordRequestSession({
611
611
const requestSession = requestIsolationScope . getScopeData ( ) . sdkProcessingMetadata . requestSession ;
612
612
613
613
if ( client && requestSession ) {
614
- DEBUG_BUILD && logger . debug ( `Recorded request session with status: ${ requestSession . status } ` ) ;
614
+ DEBUG_BUILD && debug . log ( `Recorded request session with status: ${ requestSession . status } ` ) ;
615
615
616
616
const roundedDate = new Date ( ) ;
617
617
roundedDate . setSeconds ( 0 , 0 ) ;
@@ -624,7 +624,7 @@ export function recordRequestSession({
624
624
if ( existingClientAggregate ) {
625
625
existingClientAggregate [ dateBucketKey ] = bucket ;
626
626
} else {
627
- DEBUG_BUILD && logger . debug ( 'Opened new request session aggregate.' ) ;
627
+ DEBUG_BUILD && debug . log ( 'Opened new request session aggregate.' ) ;
628
628
const newClientAggregate = { [ dateBucketKey ] : bucket } ;
629
629
clientToRequestSessionAggregatesMap . set ( client , newClientAggregate ) ;
630
630
@@ -645,11 +645,11 @@ export function recordRequestSession({
645
645
} ;
646
646
647
647
const unregisterClientFlushHook = client . on ( 'flush' , ( ) => {
648
- DEBUG_BUILD && logger . debug ( 'Sending request session aggregate due to client flush' ) ;
648
+ DEBUG_BUILD && debug . log ( 'Sending request session aggregate due to client flush' ) ;
649
649
flushPendingClientAggregates ( ) ;
650
650
} ) ;
651
651
const timeout = setTimeout ( ( ) => {
652
- DEBUG_BUILD && logger . debug ( 'Sending request session aggregate due to flushing schedule' ) ;
652
+ DEBUG_BUILD && debug . log ( 'Sending request session aggregate due to flushing schedule' ) ;
653
653
flushPendingClientAggregates ( ) ;
654
654
} , sessionFlushingDelayMS ) . unref ( ) ;
655
655
}
0 commit comments