@@ -30,6 +30,8 @@ import { getRequestInfo } from './vendor/getRequestInfo';
30
30
type Http = typeof http ;
31
31
type Https = typeof https ;
32
32
33
+ const INSTRUMENTATION_NAME = '@sentry/instrumentation-http' ;
34
+
33
35
export type SentryHttpInstrumentationOptions = InstrumentationConfig & {
34
36
/**
35
37
* Whether breadcrumbs should be recorded for requests.
@@ -101,7 +103,7 @@ const MAX_BODY_BYTE_LENGTH = 1024 * 1024;
101
103
*/
102
104
export class SentryHttpInstrumentation extends InstrumentationBase < SentryHttpInstrumentationOptions > {
103
105
public constructor ( config : SentryHttpInstrumentationOptions = { } ) {
104
- super ( '@sentry/instrumentation-http' , VERSION , config ) ;
106
+ super ( INSTRUMENTATION_NAME , VERSION , config ) ;
105
107
}
106
108
107
109
/** @inheritdoc */
@@ -377,6 +379,10 @@ function patchRequestToCaptureBody(req: IncomingMessage, isolationScope: Scope):
377
379
apply : ( target , thisArg , args : Parameters < typeof req . on > ) => {
378
380
const [ event , listener , ...restArgs ] = args ;
379
381
382
+ if ( DEBUG_BUILD ) {
383
+ logger . log ( INSTRUMENTATION_NAME , 'Patching request.on' , event ) ;
384
+ }
385
+
380
386
if ( event === 'data' ) {
381
387
const callback = new Proxy ( listener , {
382
388
apply : ( target , thisArg , args : Parameters < typeof listener > ) => {
@@ -387,7 +393,8 @@ function patchRequestToCaptureBody(req: IncomingMessage, isolationScope: Scope):
387
393
chunks . push ( chunk ) ;
388
394
} else if ( DEBUG_BUILD ) {
389
395
logger . log (
390
- `Dropping request body chunk because it maximum body length of ${ MAX_BODY_BYTE_LENGTH } b is exceeded.` ,
396
+ INSTRUMENTATION_NAME ,
397
+ `Dropping request body chunk because maximum body length of ${ MAX_BODY_BYTE_LENGTH } b is exceeded.` ,
391
398
) ;
392
399
}
393
400
@@ -410,8 +417,10 @@ function patchRequestToCaptureBody(req: IncomingMessage, isolationScope: Scope):
410
417
const normalizedRequest = { data : body } satisfies RequestEventData ;
411
418
isolationScope . setSDKProcessingMetadata ( { normalizedRequest } ) ;
412
419
}
413
- } catch {
414
- // ignore errors here
420
+ } catch ( error ) {
421
+ if ( DEBUG_BUILD ) {
422
+ logger . error ( INSTRUMENTATION_NAME , 'Error building captured request body' , error ) ;
423
+ }
415
424
}
416
425
417
426
return Reflect . apply ( target , thisArg , args ) ;
@@ -445,8 +454,10 @@ function patchRequestToCaptureBody(req: IncomingMessage, isolationScope: Scope):
445
454
return Reflect . apply ( target , thisArg , args ) ;
446
455
} ,
447
456
} ) ;
448
- } catch {
449
- // ignore errors if we can't patch stuff
457
+ } catch ( error ) {
458
+ if ( DEBUG_BUILD ) {
459
+ logger . error ( INSTRUMENTATION_NAME , 'Error patching request to capture body' , error ) ;
460
+ }
450
461
}
451
462
}
452
463
0 commit comments