@@ -65,6 +65,12 @@ export type SentryHttpInstrumentationOptions = InstrumentationConfig & {
65
65
*/
66
66
ignoreStaticAssets ?: boolean ;
67
67
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
+
68
74
/**
69
75
* Do not capture breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.
70
76
* For the scope of this instrumentation, this callback only controls breadcrumb creation.
@@ -174,6 +180,8 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
174
180
// but we only want to register them once, whichever is loaded first
175
181
let hasRegisteredHandlers = false ;
176
182
183
+ const spansEnabled = this . getConfig ( ) . spans ?? true ;
184
+
177
185
const onHttpServerRequestStart = ( ( _data : unknown ) => {
178
186
const data = _data as { server : http . Server } ;
179
187
instrumentServer ( data . server , {
@@ -186,7 +194,7 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
186
194
trackIncomingRequestsAsSessions : this . getConfig ( ) . trackIncomingRequestsAsSessions ,
187
195
sessionFlushingDelayMS : this . getConfig ( ) . sessionFlushingDelayMS ?? 60_000 ,
188
196
ignoreStaticAssets : this . getConfig ( ) . ignoreStaticAssets ,
189
- spans : this . getConfig ( ) . spans ?? true ,
197
+ spans : spansEnabled && ! this . getConfig ( ) . disableIncomingRequestSpans ,
190
198
} ) ;
191
199
} ) satisfies ChannelListener ;
192
200
0 commit comments