@@ -79,11 +79,8 @@ export function makeNodeTransport(options: NodeTransportOptions): Transport {
7979 ? ( new HttpsProxyAgent ( proxy ) as http . Agent )
8080 : new nativeHttpModule . Agent ( { keepAlive, maxSockets : 30 , timeout : 2000 } ) ;
8181
82- // This ensures we do not generate any spans in OpenTelemetry for the transport
83- return suppressTracing ( ( ) => {
84- const requestExecutor = createRequestExecutor ( options , options . httpModule ?? nativeHttpModule , agent ) ;
85- return createTransport ( options , requestExecutor ) ;
86- } ) ;
82+ const requestExecutor = createRequestExecutor ( options , options . httpModule ?? nativeHttpModule , agent ) ;
83+ return createTransport ( options , requestExecutor ) ;
8784}
8885
8986/**
@@ -122,54 +119,59 @@ function createRequestExecutor(
122119 const { hostname, pathname, port, protocol, search } = new URL ( options . url ) ;
123120 return function makeRequest ( request : TransportRequest ) : Promise < TransportMakeRequestResponse > {
124121 return new Promise ( ( resolve , reject ) => {
125- let body = streamFromBody ( request . body ) ;
126-
127- const headers : Record < string , string > = { ...options . headers } ;
128-
129- if ( request . body . length > GZIP_THRESHOLD ) {
130- headers [ 'content-encoding' ] = 'gzip' ;
131- body = body . pipe ( createGzip ( ) ) ;
132- }
133-
134- const req = httpModule . request (
135- {
136- method : 'POST' ,
137- agent,
138- headers,
139- hostname,
140- path : `${ pathname } ${ search } ` ,
141- port,
142- protocol,
143- ca : options . caCerts ,
144- } ,
145- res => {
146- res . on ( 'data' , ( ) => {
147- // Drain socket
148- } ) ;
149-
150- res . on ( 'end' , ( ) => {
151- // Drain socket
152- } ) ;
153-
154- res . setEncoding ( 'utf8' ) ;
155-
156- // "Key-value pairs of header names and values. Header names are lower-cased."
157- // https://nodejs.org/api/http.html#http_message_headers
158- const retryAfterHeader = res . headers [ 'retry-after' ] ?? null ;
159- const rateLimitsHeader = res . headers [ 'x-sentry-rate-limits' ] ?? null ;
160-
161- resolve ( {
162- statusCode : res . statusCode ,
163- headers : {
164- 'retry-after' : retryAfterHeader ,
165- 'x-sentry-rate-limits' : Array . isArray ( rateLimitsHeader ) ? rateLimitsHeader [ 0 ] || null : rateLimitsHeader ,
166- } ,
167- } ) ;
168- } ,
169- ) ;
170-
171- req . on ( 'error' , reject ) ;
172- body . pipe ( req ) ;
122+ // This ensures we do not generate any spans in OpenTelemetry for the transport
123+ suppressTracing ( ( ) => {
124+ let body = streamFromBody ( request . body ) ;
125+
126+ const headers : Record < string , string > = { ...options . headers } ;
127+
128+ if ( request . body . length > GZIP_THRESHOLD ) {
129+ headers [ 'content-encoding' ] = 'gzip' ;
130+ body = body . pipe ( createGzip ( ) ) ;
131+ }
132+
133+ const req = httpModule . request (
134+ {
135+ method : 'POST' ,
136+ agent,
137+ headers,
138+ hostname,
139+ path : `${ pathname } ${ search } ` ,
140+ port,
141+ protocol,
142+ ca : options . caCerts ,
143+ } ,
144+ res => {
145+ res . on ( 'data' , ( ) => {
146+ // Drain socket
147+ } ) ;
148+
149+ res . on ( 'end' , ( ) => {
150+ // Drain socket
151+ } ) ;
152+
153+ res . setEncoding ( 'utf8' ) ;
154+
155+ // "Key-value pairs of header names and values. Header names are lower-cased."
156+ // https://nodejs.org/api/http.html#http_message_headers
157+ const retryAfterHeader = res . headers [ 'retry-after' ] ?? null ;
158+ const rateLimitsHeader = res . headers [ 'x-sentry-rate-limits' ] ?? null ;
159+
160+ resolve ( {
161+ statusCode : res . statusCode ,
162+ headers : {
163+ 'retry-after' : retryAfterHeader ,
164+ 'x-sentry-rate-limits' : Array . isArray ( rateLimitsHeader )
165+ ? rateLimitsHeader [ 0 ] || null
166+ : rateLimitsHeader ,
167+ } ,
168+ } ) ;
169+ } ,
170+ ) ;
171+
172+ req . on ( 'error' , reject ) ;
173+ body . pipe ( req ) ;
174+ } ) ;
173175 } ) ;
174176 } ;
175177}
0 commit comments