@@ -196,9 +196,7 @@ export function _shouldUseOtelHttpInstrumentation(
196196 */
197197export const httpIntegration = defineIntegration ( ( options : HttpOptions = { } ) => {
198198 const spans = options . spans ?? true ;
199- const clientOptions = ( getClient < NodeClient > ( ) ?. getOptions ( ) || { } ) as Partial < NodeClientOptions > ;
200- const useOtelHttpInstrumentation = _shouldUseOtelHttpInstrumentation ( options , clientOptions ) ;
201- const disableIncomingRequestSpans = options . disableIncomingRequestSpans ?? ! hasSpansEnabled ( clientOptions ) ;
199+ const disableIncomingRequestSpans = options . disableIncomingRequestSpans ;
202200
203201 const serverOptions = {
204202 sessions : options . trackIncomingRequestsAsSessions ,
@@ -214,29 +212,34 @@ export const httpIntegration = defineIntegration((options: HttpOptions = {}) =>
214212 instrumentation : options . instrumentation ,
215213 } satisfies Parameters < typeof httpServerSpansIntegration > [ 0 ] ;
216214
217- const sentryHttpInstrumentationOptions = {
218- breadcrumbs : options . breadcrumbs ,
219- propagateTraceInOutgoingRequests : ! useOtelHttpInstrumentation ,
220- ignoreOutgoingRequests : options . ignoreOutgoingRequests ,
221- } satisfies SentryHttpInstrumentationOptions ;
222-
223215 const server = httpServerIntegration ( serverOptions ) ;
224216 const serverSpans = httpServerSpansIntegration ( serverSpansOptions ) ;
225217
226- const enabledServerSpans = spans && ! disableIncomingRequestSpans ;
218+ const enableServerSpans = spans && ! disableIncomingRequestSpans ;
227219
228220 return {
229221 name : INTEGRATION_NAME ,
230222
231223 setup ( client : NodeClient ) {
232- if ( enabledServerSpans ) {
224+ const clientOptions = client . getOptions ( ) ;
225+
226+ if ( enableServerSpans && hasSpansEnabled ( clientOptions ) ) {
233227 serverSpans . setup ( client ) ;
234228 }
235229 } ,
236230
237231 setupOnce ( ) {
232+ const clientOptions = ( getClient < NodeClient > ( ) ?. getOptions ( ) || { } ) satisfies Partial < NodeClientOptions > ;
233+ const useOtelHttpInstrumentation = _shouldUseOtelHttpInstrumentation ( options , clientOptions ) ;
234+
238235 server . setupOnce ( ) ;
239236
237+ const sentryHttpInstrumentationOptions = {
238+ breadcrumbs : options . breadcrumbs ,
239+ propagateTraceInOutgoingRequests : ! useOtelHttpInstrumentation ,
240+ ignoreOutgoingRequests : options . ignoreOutgoingRequests ,
241+ } satisfies SentryHttpInstrumentationOptions ;
242+
240243 // This is Sentry-specific instrumentation for outgoing request breadcrumbs & trace propagation
241244 instrumentSentryHttp ( sentryHttpInstrumentationOptions ) ;
242245
@@ -247,7 +250,7 @@ export const httpIntegration = defineIntegration((options: HttpOptions = {}) =>
247250 }
248251 } ,
249252 processEvent ( event ) {
250- if ( enabledServerSpans ) {
253+ if ( enableServerSpans ) {
251254 return serverSpans . processEvent ( event ) ;
252255 }
253256 return event ;
0 commit comments