@@ -16,13 +16,6 @@ export const DEFAULT_TRACE_PROPAGATION_TARGETS = ['localhost', /^\/(?!\/)/];
1616
1717/** Options for Request Instrumentation */
1818export interface RequestInstrumentationOptions {
19- /**
20- * Allow experiments for the request instrumentation.
21- */
22- _experiments : Partial < {
23- enableHTTPTimings : boolean ;
24- } > ;
25-
2619 /**
2720 * @deprecated Will be removed in v8.
2821 * Use `shouldCreateSpanForRequest` to control span creation and `tracePropagationTargets` to control
@@ -52,6 +45,13 @@ export interface RequestInstrumentationOptions {
5245 */
5346 traceXHR : boolean ;
5447
48+ /**
49+ * If true, Sentry will capture http timings and add them to the corresponding http spans.
50+ *
51+ * Default: true
52+ */
53+ enableHTTPTimings : boolean ;
54+
5555 /**
5656 * This function will be called before creating a span for a request with the given url.
5757 * Return false if you don't want a span for the given url.
@@ -114,16 +114,23 @@ type PolymorphicRequestHeaders =
114114export const defaultRequestInstrumentationOptions : RequestInstrumentationOptions = {
115115 traceFetch : true ,
116116 traceXHR : true ,
117+ enableHTTPTimings : true ,
117118 // TODO (v8): Remove this property
118119 tracingOrigins : DEFAULT_TRACE_PROPAGATION_TARGETS ,
119120 tracePropagationTargets : DEFAULT_TRACE_PROPAGATION_TARGETS ,
120- _experiments : { } ,
121121} ;
122122
123123/** Registers span creators for xhr and fetch requests */
124124export function instrumentOutgoingRequests ( _options ?: Partial < RequestInstrumentationOptions > ) : void {
125- // eslint-disable-next-line deprecation/deprecation
126- const { traceFetch, traceXHR, tracePropagationTargets, tracingOrigins, shouldCreateSpanForRequest, _experiments } = {
125+ const {
126+ traceFetch,
127+ traceXHR,
128+ tracePropagationTargets,
129+ // eslint-disable-next-line deprecation/deprecation
130+ tracingOrigins,
131+ shouldCreateSpanForRequest,
132+ enableHTTPTimings,
133+ } = {
127134 traceFetch : defaultRequestInstrumentationOptions . traceFetch ,
128135 traceXHR : defaultRequestInstrumentationOptions . traceXHR ,
129136 ..._options ,
@@ -143,7 +150,7 @@ export function instrumentOutgoingRequests(_options?: Partial<RequestInstrumenta
143150 if ( traceFetch ) {
144151 addInstrumentationHandler ( 'fetch' , ( handlerData : FetchData ) => {
145152 const createdSpan = fetchCallback ( handlerData , shouldCreateSpan , shouldAttachHeadersWithTargets , spans ) ;
146- if ( _experiments ?. enableHTTPTimings && createdSpan ) {
153+ if ( enableHTTPTimings && createdSpan ) {
147154 addHTTPTimings ( createdSpan ) ;
148155 }
149156 } ) ;
@@ -152,7 +159,7 @@ export function instrumentOutgoingRequests(_options?: Partial<RequestInstrumenta
152159 if ( traceXHR ) {
153160 addInstrumentationHandler ( 'xhr' , ( handlerData : XHRData ) => {
154161 const createdSpan = xhrCallback ( handlerData , shouldCreateSpan , shouldAttachHeadersWithTargets , spans ) ;
155- if ( _experiments ?. enableHTTPTimings && createdSpan ) {
162+ if ( enableHTTPTimings && createdSpan ) {
156163 addHTTPTimings ( createdSpan ) ;
157164 }
158165 } ) ;
0 commit comments