@@ -16,13 +16,6 @@ export const DEFAULT_TRACE_PROPAGATION_TARGETS = ['localhost', /^\/(?!\/)/];
16
16
17
17
/** Options for Request Instrumentation */
18
18
export interface RequestInstrumentationOptions {
19
- /**
20
- * Allow experiments for the request instrumentation.
21
- */
22
- _experiments : Partial < {
23
- enableHTTPTimings : boolean ;
24
- } > ;
25
-
26
19
/**
27
20
* @deprecated Will be removed in v8.
28
21
* Use `shouldCreateSpanForRequest` to control span creation and `tracePropagationTargets` to control
@@ -52,6 +45,13 @@ export interface RequestInstrumentationOptions {
52
45
*/
53
46
traceXHR : boolean ;
54
47
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
+
55
55
/**
56
56
* This function will be called before creating a span for a request with the given url.
57
57
* Return false if you don't want a span for the given url.
@@ -114,16 +114,23 @@ type PolymorphicRequestHeaders =
114
114
export const defaultRequestInstrumentationOptions : RequestInstrumentationOptions = {
115
115
traceFetch : true ,
116
116
traceXHR : true ,
117
+ enableHTTPTimings : true ,
117
118
// TODO (v8): Remove this property
118
119
tracingOrigins : DEFAULT_TRACE_PROPAGATION_TARGETS ,
119
120
tracePropagationTargets : DEFAULT_TRACE_PROPAGATION_TARGETS ,
120
- _experiments : { } ,
121
121
} ;
122
122
123
123
/** Registers span creators for xhr and fetch requests */
124
124
export 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
+ } = {
127
134
traceFetch : defaultRequestInstrumentationOptions . traceFetch ,
128
135
traceXHR : defaultRequestInstrumentationOptions . traceXHR ,
129
136
..._options ,
@@ -143,7 +150,7 @@ export function instrumentOutgoingRequests(_options?: Partial<RequestInstrumenta
143
150
if ( traceFetch ) {
144
151
addInstrumentationHandler ( 'fetch' , ( handlerData : FetchData ) => {
145
152
const createdSpan = fetchCallback ( handlerData , shouldCreateSpan , shouldAttachHeadersWithTargets , spans ) ;
146
- if ( _experiments ?. enableHTTPTimings && createdSpan ) {
153
+ if ( enableHTTPTimings && createdSpan ) {
147
154
addHTTPTimings ( createdSpan ) ;
148
155
}
149
156
} ) ;
@@ -152,7 +159,7 @@ export function instrumentOutgoingRequests(_options?: Partial<RequestInstrumenta
152
159
if ( traceXHR ) {
153
160
addInstrumentationHandler ( 'xhr' , ( handlerData : XHRData ) => {
154
161
const createdSpan = xhrCallback ( handlerData , shouldCreateSpan , shouldAttachHeadersWithTargets , spans ) ;
155
- if ( _experiments ?. enableHTTPTimings && createdSpan ) {
162
+ if ( enableHTTPTimings && createdSpan ) {
156
163
addHTTPTimings ( createdSpan ) ;
157
164
}
158
165
} ) ;
0 commit comments