Skip to content

Commit 138df69

Browse files
authored
feat(js): Add documentation for new browserTracingIntegration options (#13943)
adds documentation for new options available in `browserTracingIntegration`: - `ignorePerformanceApiSpans` - `ignoreResourceSpans` - `onRequestSpanStart` (this has been around for some time but we never documented it, oops) Furthermore, I decided to give this page a little face lift by using the `<SdkOption>` component for a unified appearance of options. This also included adding a table row for "Available Since" to the `<SdkOption>` component, since a lot of these option descriptions previously used texts or alerts to specify the min SDK version. Also made some minor adjustments to outdated documentation on related pages.
1 parent 92dd1c9 commit 138df69

File tree

4 files changed

+116
-41
lines changed

4 files changed

+116
-41
lines changed

docs/platforms/javascript/common/configuration/integrations/browsertracing.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ Sentry.init({
3838
integrations: [Sentry.browserTracingIntegration()],
3939
});
4040
```
41+
42+
See <PlatformLink to="/tracing/instrumentation/automatic-instrumentation/#configuration-options">Configuration Options</PlatformLink> for a full list of availalable options for `browserTracingIntegration`

docs/platforms/javascript/common/tracing/instrumentation/automatic-instrumentation.mdx

Lines changed: 93 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Sentry.init({
5050

5151
Supported options:
5252

53-
### tracePropagationTargets
53+
<SdkOption name="tracePropagationTargets" type='Array<string | RegExp>' defaultValue={'[\'localhost\', /^\\\/$/]'}>
5454

5555
<Alert>
5656

@@ -68,90 +68,92 @@ The default value of `tracePropagationTargets` is `['localhost', /^\//]`. This m
6868

6969
You will need to configure your web server [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers) to allow the `sentry-trace` and `baggage` headers. The configuration might look like `"Access-Control-Allow-Headers: sentry-trace"` and `"Access-Control-Allow-Headers: baggage"`, but it depends on your set up. If you do not allow the two headers, the request might be blocked.
7070

71-
### beforeStartSpan
71+
</SdkOption>
72+
73+
<SdkOption name="beforeStartSpan" type='(options: StartSpanOptions) => StartSpanOptions'>
7274

7375
`beforeStartSpan` is called at the start of every `pageload` or `navigation` span, and is passed an object containing data about the span which will be started. With `beforeStartSpan` you can modify that data.
7476

7577
<PlatformContent includePath="performance/beforeNavigate-example" />
7678

79+
</SdkOption>
80+
7781
<Alert>
7882
If you're using React, read our docs to learn how to set up your [React Router
7983
integration](/platforms/javascript/guides/react/configuration/integrations/react-router/).
8084
</Alert>
8185

82-
### shouldCreateSpanForRequest
86+
<SdkOption name="shouldCreateSpanForRequest" type='(url: string) => boolean'>
8387

8488
This function can be used to filter out unwanted spans such as XHRs running
85-
health checks or something similar. If this function isn't specified, spans
86-
will be created for all requests.
89+
health checks or something similar.
8790

8891
<PlatformContent includePath="performance/filter-span-example" />
8992

90-
### idleTimeout
93+
By default, spans will be created for all requests.
94+
95+
</SdkOption>
96+
97+
<SdkOption name="onRequestSpanStart" type="(span: Span, requestInformation: { headers?: WebFetchHeaders }): void">
98+
99+
This callback is invoked directly after a span is started for an outgoing fetch or XHR request.
100+
You can use it to annotate the span with additional data or attributes, for example by setting attributes based on the passed request headers.
101+
102+
</SdkOption>
103+
104+
<SdkOption name="idleTimeout" type='number' defaultValue='1000'>
91105

92106
The idle time, measured in ms, to wait until the pageload/navigation span will be finished, if there are no unfinished spans. The pageload/navigation span will use the end timestamp of the last finished span as the endtime.
93107

94-
The default is `1000`.
108+
</SdkOption>
95109

96-
### finalTimeout
110+
<SdkOption name="finalTimeout" type='number' defaultValue='30000'>
97111

98112
The maximum duration of the pageload/naivgation span, measured in ms. If the duration exceeds the `finalTimeout` value, it will be finished.
99113

100-
The default is `30000`.
114+
</SdkOption>
101115

102-
### childSpanTimeout
116+
<SdkOption name="childSpanTimeout" type='number' defaultValue='15000'>
103117

104118
The time, measured in ms, that a child span may run. If the last started child span is still running for more than this time, the pageload/navigation span will be finished.
105119

106-
The default is `15000`.
120+
</SdkOption>
107121

108-
### instrumentNavigation
122+
<SdkOption name="instrumentNavigation" type='boolean' defaultValue='true'>
109123

110124
This flag enables or disables creation of `navigation` span on history changes.
111125

112-
The default is `true`.
126+
</SdkOption>
113127

114-
### instrumentPageLoad
128+
<SdkOption name="instrumentPageLoad" type='boolean' defaultValue='true'>
115129

116130
This flag enables or disables creation of `pageload` span on first pageload.
117131

118-
The default is `true`.
132+
</SdkOption>
119133

120-
### markBackgroundSpans
134+
<SdkOption name="markBackgroundSpans" type='boolean' defaultValue='true'>
121135

122136
This option flags pageload/navigation spans when tabs are moved to the background with "cancelled". Because browser background tab timing is not suited for precise measurements of operations and can affect your statistics in nondeterministic ways, we recommend that this option be enabled.
123137

124-
The default is `true`.
138+
</SdkOption>
125139

126-
### enableLongTask
140+
<SdkOption name="enableLongTask" type='boolean' defaultValue='true'>
127141

128142
This option determines whether spans for long tasks automatically get created.
129143

130-
The default is `true`.
131-
132-
### enableLongAnimationFrame
144+
</SdkOption>
133145

134-
<Alert>
135-
The `enableLongAnimationFrame` option requires SDK [version
136-
8.18.0](https://github.com/getsentry/sentry-javascript/releases/tag/8.18.0) or
137-
higher.
138-
</Alert>
146+
<SdkOption name="enableLongAnimationFrame" type='boolean' defaultValue='true' availableSince='8.18.0'>
139147

140-
This option determines whether spans for long animation frames get created automatically. If both `enableLongAnimationFrame` and `enableLongTask` are enabled, Sentry will send long animation frames and fallback to long tasks (if long animation frames aren't supported by the browser).
148+
This option determines whether spans for long animation frames get created automatically. If both `enableLongAnimationFrame` and [`enableLongTask`](#enableLongTask) are enabled, Sentry will send long animation frames and fallback to long tasks (if long animation frames aren't supported by the browser).
141149

142-
The default is `true`.
150+
</SdkOption>
143151

144-
### enableInp
145-
146-
<Alert>
147-
The `enableInp` option requires SDK [version
148-
7.104.0](https://github.com/getsentry/sentry-javascript/releases/tag/7.104.0)
149-
or higher.
150-
</Alert>
152+
<SdkOption name="enableInp" type='boolean' defaultValue='true' availableSince='7.104.0' defaultNote="See note">
151153

152154
This option determines whether interactions spans automatically get created when an [Interaction to Next Paint (INP)](/product/insights/web-vitals/web-vitals-concepts/#interaction-to-next-paint-inp) event is detected. Interactions are scored and surfaced in the [Web Vitals](/product/insights/web-vitals/) module.
153155

154-
The default is `true` in `8.x` of the SDK, and `false` in `7.x`.
156+
The default is `true` starting with SDK version `8.x` and `false` in `7.x`.
155157

156158
<Alert>
157159
INP samples currently incur no cost to enable at Sentry. Basic samples contain limited information such as the interaction target, latency, and user. You may wish to enrich your INP samples by setting up [Session Replays](/platforms/javascript/session-replay/) and/or setting up [Browser Profiling](/platforms/javascript/profiling/) instrumentation around your interactive elements to gain further insights into your slowest interactions.
@@ -162,8 +164,62 @@ Please note that any Session Replays and Browser Profiles used this way will inc
162164

163165
<PlatformContent includePath="performance/enable-inp-example" />
164166

165-
### interactionsSampleRate
167+
</SdkOption>
168+
169+
<SdkOption name="interactionsSampleRate" type='number' defaultValue='1.0'>
166170

167171
This option determines the sample rate of INP spans. `interactionsSampleRate` is applied on top of `tracesSampleRate`, therefore if your `interactionsSampleRate` is set to `0.5` and your `tracesSampleRate` is set to `0.1`, the outcome will be `0.05`.
168172

169173
The default is `1.0`.
174+
175+
</SdkOption>
176+
177+
<SdkOption name="ignoreResourceSpans" type='Array<string>' defaultValue='[]' availableSince='9.23.0'>
178+
179+
This option determines which categories or resource spans should be ignored. The resource categories are the span `op`s (for example `resource.script` or `resource.img`)
180+
181+
```JavaScript
182+
Sentry.init({
183+
// ...
184+
integrations: [
185+
Sentry.browserTracingIntegration({
186+
ignoreResourceSpans: ['resource.css', 'resource.script'],
187+
}),
188+
],
189+
});
190+
```
191+
192+
By default, all resource spans are captured.
193+
194+
</SdkOption>
195+
196+
<SdkOption name="ignorePerformanceApiSpans" type='Array<string | RegExp>' defaultValue='[]' availableSince='9.23.0'>
197+
198+
This option allows you to ignore certain spans created from the following browser Performance APIs:
199+
200+
- [`performance.mark(...)`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark)
201+
- [`performance.measure(...)`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure)
202+
203+
Any mark or measure entries matching the strings or regular expressions in the passed array will not be emitted as `mark` or `measure` spans.
204+
205+
```JavaScript
206+
Sentry.init({
207+
integrations: [
208+
Sentry.browserTracingIntegration({
209+
ignorePerformanceApiSpans: ['myMeasurement', /myMark/],
210+
}),
211+
],
212+
});
213+
214+
// no spans will not be created for these:
215+
performance.mark('myMark');
216+
performance.measure('myMeasurement');
217+
218+
// spans will be created for these:
219+
performance.mark('authenticated');
220+
performance.measure('input-duration', ...);
221+
```
222+
223+
By default, all performance API spans are captured.
224+
225+
</SdkOption>

docs/product/insights/frontend/web-vitals/web-vitals-concepts.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Google considers Core Web Vitals to be the most important metrics for measuring
2424
### Interaction to Next Paint (INP)
2525

2626
<Alert>
27-
On March 12, 2024, Interaction to Next Paint (INP) replaced First Input Delay (FID) as a Core Web Vital. Prior to this, INP was an experimental metric that Sentry did not collect. To begin collecting INP measurements, make sure your JavaScript SDK version is [7.104.0](https://github.com/getsentry/sentry-javascript/releases/tag/7.104.0) or higher and that the option [`enableInp`](/platforms/javascript/tracing/instrumentation/automatic-instrumentation/#enableinp) is on.
27+
On March 12, 2024, Interaction to Next Paint (INP) replaced First Input Delay (FID) as a Core Web Vital. Prior to this, INP was an experimental metric that Sentry did not collect. To begin collecting INP measurements, make sure your JavaScript SDK version is [7.104.0](https://github.com/getsentry/sentry-javascript/releases/tag/7.104.0) or higher and that the option [`enableInp`](/platforms/javascript/tracing/instrumentation/automatic-instrumentation/#enableinp) is on (starting with version `8.0.0`, `enableInp` is enabled by default).
2828
</Alert>
2929

3030
[Interaction to Next Paint (INP)](https://web.dev/articles/inp) measures the time from when a user interacts with a page (through a click, tap, or keyboard input) to when the next paint (rendering of content on the screen) occurs. INP aims to assess how quickly users see a response from the website after taking an action, which is crucial for providing a smooth and responsive user experience.

src/components/sdkOption.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ import {SdkDefinition, SdkDefinitionTable} from './sdkDefinition';
99
type Props = {
1010
name: string;
1111
type: string;
12+
availableSince?: string;
1213
categorySupported?: PlatformCategory[];
1314
children?: React.ReactNode;
15+
defaultNote?: string;
1416
defaultValue?: string;
1517
envVar?: string;
1618
};
@@ -19,7 +21,9 @@ export function SdkOption({
1921
name,
2022
children,
2123
type,
24+
availableSince,
2225
defaultValue,
26+
defaultNote,
2327
envVar,
2428
categorySupported = [],
2529
}: Props) {
@@ -28,9 +32,13 @@ export function SdkOption({
2832
return (
2933
<SdkDefinition name={name} categorySupported={categorySupported}>
3034
<SdkDefinitionTable>
35+
{availableSince && (
36+
<OptionDefRow label="Available since" value={availableSince} />
37+
)}
3138
{type && <OptionDefRow label="Type" value={type} />}
32-
{defaultValue && <OptionDefRow label="Default" value={defaultValue} />}
33-
39+
{defaultValue && (
40+
<OptionDefRow label="Default" value={defaultValue} note={defaultNote} />
41+
)}
3442
<PlatformCategorySection supported={['server', 'serverless']}>
3543
<PlatformSection notSupported={['javascript.nextjs']}>
3644
{envVar && <OptionDefRow label="ENV Variable" value={envVar} />}
@@ -46,12 +54,21 @@ export function SdkOption({
4654
);
4755
}
4856

49-
function OptionDefRow({label, value}: {label: string; value: string}) {
57+
function OptionDefRow({
58+
label,
59+
value,
60+
note,
61+
}: {
62+
label: string;
63+
value: string;
64+
note?: string;
65+
}) {
5066
return (
5167
<tr>
5268
<th>{label}</th>
5369
<td>
5470
<code>{value}</code>
71+
{note && <small> ({note})</small>}
5572
</td>
5673
</tr>
5774
);

0 commit comments

Comments
 (0)