Skip to content

Commit 564af01

Browse files
k-fishAbhiPrasad
andauthored
feat(tracing): Bring http timings out of experiment (#8563)
Co-authored-by: Abhijeet Prasad <aprasad@sentry.io>
1 parent c2bd091 commit 564af01

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

packages/tracing-internal/src/browser/browsertracing.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ export interface BrowserTracingOptions extends RequestInstrumentationOptions {
105105
_experiments: Partial<{
106106
enableLongTask: boolean;
107107
enableInteractions: boolean;
108-
enableHTTPTimings: boolean;
109108
onStartRouteTransaction: (t: Transaction | undefined, ctx: TransactionContext, getCurrentHub: () => Hub) => void;
110109
}>;
111110

@@ -140,6 +139,7 @@ const DEFAULT_BROWSER_TRACING_OPTIONS: BrowserTracingOptions = {
140139
startTransactionOnLocationChange: true,
141140
startTransactionOnPageLoad: true,
142141
enableLongTask: true,
142+
_experiments: {},
143143
...defaultRequestInstrumentationOptions,
144144
};
145145

@@ -230,6 +230,7 @@ export class BrowserTracing implements Integration {
230230
traceFetch,
231231
traceXHR,
232232
shouldCreateSpanForRequest,
233+
enableHTTPTimings,
233234
_experiments,
234235
} = this.options;
235236

@@ -277,9 +278,7 @@ export class BrowserTracing implements Integration {
277278
traceXHR,
278279
tracePropagationTargets,
279280
shouldCreateSpanForRequest,
280-
_experiments: {
281-
enableHTTPTimings: _experiments.enableHTTPTimings,
282-
},
281+
enableHTTPTimings,
283282
});
284283
}
285284

packages/tracing-internal/src/browser/request.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ export const DEFAULT_TRACE_PROPAGATION_TARGETS = ['localhost', /^\/(?!\/)/];
1616

1717
/** Options for Request Instrumentation */
1818
export 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 =
114114
export 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 */
124124
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+
} = {
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
});

packages/tracing-internal/test/browser/browsertracing.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ conditionalTest({ min: 10 })('BrowserTracing', () => {
9595

9696
expect(browserTracing.options).toEqual({
9797
enableLongTask: true,
98+
_experiments: {},
9899
...TRACING_DEFAULTS,
99100
markBackgroundTransactions: true,
100101
routingInstrumentation: instrumentRoutingWithDefaults,
@@ -132,6 +133,7 @@ conditionalTest({ min: 10 })('BrowserTracing', () => {
132133

133134
expect(browserTracing.options).toEqual({
134135
enableLongTask: false,
136+
_experiments: {},
135137
...TRACING_DEFAULTS,
136138
markBackgroundTransactions: true,
137139
routingInstrumentation: instrumentRoutingWithDefaults,
@@ -246,7 +248,7 @@ conditionalTest({ min: 10 })('BrowserTracing', () => {
246248
traceFetch: true,
247249
traceXHR: true,
248250
tracePropagationTargets: ['something'],
249-
_experiments: {},
251+
enableHTTPTimings: true,
250252
});
251253
});
252254

@@ -260,7 +262,7 @@ conditionalTest({ min: 10 })('BrowserTracing', () => {
260262
});
261263

262264
expect(instrumentOutgoingRequestsMock).toHaveBeenCalledWith({
263-
_experiments: {},
265+
enableHTTPTimings: true,
264266
traceFetch: true,
265267
traceXHR: true,
266268
tracePropagationTargets: ['something-else'],

0 commit comments

Comments
 (0)