@@ -65,6 +65,12 @@ export type SentryHttpInstrumentationOptions = InstrumentationConfig & {
6565 */
6666 ignoreStaticAssets ?: boolean ;
6767
68+ /**
69+ * If true, do not generate spans for incoming requests at all.
70+ * This is used by Remix to avoid generating spans for incoming requests, as it generates its own spans.
71+ */
72+ disableIncomingRequestSpans ?: boolean ;
73+
6874 /**
6975 * Do not capture breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.
7076 * For the scope of this instrumentation, this callback only controls breadcrumb creation.
@@ -174,6 +180,8 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
174180 // but we only want to register them once, whichever is loaded first
175181 let hasRegisteredHandlers = false ;
176182
183+ const spansEnabled = this . getConfig ( ) . spans ?? true ;
184+
177185 const onHttpServerRequestStart = ( ( _data : unknown ) => {
178186 const data = _data as { server : http . Server } ;
179187 instrumentServer ( data . server , {
@@ -186,7 +194,7 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
186194 trackIncomingRequestsAsSessions : this . getConfig ( ) . trackIncomingRequestsAsSessions ,
187195 sessionFlushingDelayMS : this . getConfig ( ) . sessionFlushingDelayMS ?? 60_000 ,
188196 ignoreStaticAssets : this . getConfig ( ) . ignoreStaticAssets ,
189- spans : this . getConfig ( ) . spans ?? true ,
197+ spans : spansEnabled && ! this . getConfig ( ) . disableIncomingRequestSpans ,
190198 } ) ;
191199 } ) satisfies ChannelListener ;
192200
0 commit comments