You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/javascript/common/distributed-tracing/index.mdx
+24Lines changed: 24 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,30 @@ What happens in the background is that Sentry uses reads and further propagates
29
29
30
30
If you run any JavaScript applications in your distributed system, make sure that those two headers are added to your CORS allowlist and won't be blocked or stripped by your proxy servers, gateways, or firewalls.
31
31
32
+
## Trace Duration
33
+
34
+
<PlatformCategorySectionsupported={["browser"]}>
35
+
36
+
In the browser, the SDK automatically starts a new trace in the following situations:
37
+
38
+
- On page load: Whenever the page is (re-)loaded, a new trace is started. At the same time, a `pageload` span is created (see <PlatformLinkto="/performance/instrumentation/automatic-instrumentation">Performance Monitoring</PlatformLink>). Once this span ends, the trace remains until the next navigation or page load. In case the server serving the initial page already started a trace and sent the necessary [HTML tags](./custom-instrumentation/#extract-tracing-information-from-html-meta-tags) to the browser, the SDK will continue this trace instead of starting a new one.
39
+
- On navigation: Whenever a user navigates (for example in a single-page application), a new trace is started. At the same time, a `navigation` span is created (see <PlatformLinkto="/performance/instrumentation/automatic-instrumentation">Performance Monitoring</PlatformLink>). Once this span ends, the trace remains until the next navigation or page load.
40
+
41
+
In both cases, this means that if you start spans after the automatic `pageload` and `navigation` spans ended, they will still be part of the same trace. This makes it easy to connect what happened before and after your span.
Copy file name to clipboardExpand all lines: platform-includes/distributed-tracing/custom-instrumentation/javascript.mdx
+24Lines changed: 24 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -173,6 +173,30 @@ In this example, tracing information is propagated to the project running at `ht
173
173
174
174
The two services are now connected with your custom distributed tracing implementation.
175
175
176
+
### Starting a New Trace
177
+
178
+
Available since SDK version `8.5.0`.
179
+
180
+
In case the SDK's [default behavior](../#trace-duration) for the trace duration does not fit your needs, you can manually start a new trace that will no longer be connected to the current (distributed) trace.
181
+
This means that spans or errors collected by the SDK during this new trace will not be connected to spans or errors collected before or after this new trace.
182
+
183
+
To start a new trace that remains valid throughout the duration of a callback, use `startNewTrace`:
Once the callback ends, the SDK will continue the previous trace (if available).
199
+
176
200
## Verification
177
201
178
202
If you make outgoing requests from your project to other services, check if the headers `sentry-trace` and `baggage` are present in the request. If so, distributed tracing is working.
0 commit comments