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: src/collections/_documentation/performance/distributed-tracing.md
+60-10Lines changed: 60 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -154,16 +154,16 @@ def process_item(item):
154
154
155
155
### JavaScript
156
156
157
-
To access our tracing features, you will need to install our Tracing integration:
157
+
To access our tracing features, you will need to install our Tracing package `@sentry/apm`:
158
158
159
159
```bash
160
160
$ npm install @sentry/browser
161
161
$ npm install @sentry/apm
162
162
```
163
163
164
-
**Sending Traces**
164
+
**Sending Traces/Transactions/Spans**
165
165
166
-
Tracing resides in the `@sentry/apm` package. You can add it to your `Sentry.init` call:
166
+
The `Tracing` integration resides in the `@sentry/apm` package. You can add it to your `Sentry.init` call:
167
167
168
168
```javascript
169
169
import*asSentryfrom'@sentry/browser';
@@ -174,6 +174,7 @@ Sentry.init({
174
174
integrations: [
175
175
newApmIntegrations.Tracing(),
176
176
],
177
+
tracesSampleRate:0.1,
177
178
});
178
179
```
179
180
@@ -186,10 +187,9 @@ import { Integrations as ApmIntegrations } from '@sentry/apm';
186
187
Sentry.init({
187
188
dsn:'___PUBLIC_DSN___',
188
189
integrations: [
189
-
newIntegrations.Tracing({
190
-
tracesSampleRate:0.1,
191
-
}),
190
+
newApmIntegrations.Tracing(),
192
191
],
192
+
tracesSampleRate:0.1,
193
193
});
194
194
```
195
195
@@ -198,6 +198,22 @@ You can pass many different options to tracing, but it comes with reasonable def
198
198
199
199
- A [transaction]({%- link _documentation/performance/performance-glossary.md -%}#transaction) for every page load
200
200
- All XHR/fetch requests as spans
201
+
- If available: Browser Resources (Scripts, CSS, Images ...)
202
+
- If available: Browser Performance API Marks
203
+
204
+
*tracingOrigins Option*
205
+
206
+
The default value of `tracingOrigins` is : `new ApmIntegrations.Tracing({tracingOrigins: ['localhost', /^\//]})`. The JavaScript SDK will attach the `sentry-trace` header to all outgoing XHR/fetch requests that contain a string in the list or match a regex. In case your frontend is making requests to a different domain you might want to add it there in order to propagate the `sentry-trace` header to the backend services, required to link transactions together as part of a single trace.
207
+
208
+
*Example:*
209
+
210
+
- A frontend application is served from `example.com`
211
+
- A backend service is served from `api.example.com`
212
+
- The frontend application makes API calls to the backend
213
+
- Then the option need to be configured like this `new ApmIntegrations.Tracing({tracingOrigins: ['api.example.com']})`
214
+
- Outgoing XHR/fetch requests to `api.example.com` would get the `sentry-trace` header attached
215
+
216
+
*NOTE:* You need to make sure your web server CORS is configured to allow the `sentry-trace` header. The configuration might look like this: `"Access-Control-Allow-Headers: sentry-trace"`, this depends a lot on your configuration. But if you are not whitelisting the `sentry-trace` header the request might be blocked.
201
217
202
218
**Using Tracing Integration for Manual Instrumentation**
203
219
@@ -210,24 +226,58 @@ The tracing integration will create a [transaction]({%- link _documentation/perf
ApmIntegrations.Tracing.finishIdleTransaction(); // This is optional
260
+
}
219
261
```
220
262
263
+
This example will send a [transaction]({%- link _documentation/performance/performance-glossary.md -%}#transaction) `shopCheckout` to Sentry, containing all outgoing requests that might have happened in `validateShoppingCartOnServer`. It also contains a `task` span that measured how long the processing took. Finally the call to `ApmIntegrations.Tracing.finshIdleTransaction()` will finish the [transaction]({%- link _documentation/performance/performance-glossary.md -%}#transaction) and send it to Sentry. Calling this is optional since the Integration would send the [transaction]({%- link _documentation/performance/performance-glossary.md -%}#transaction) after the defined `idleTimeout` (default 500ms) itself.
264
+
265
+
**What is an activity?**
266
+
267
+
The concept of an activity only exists in the `Tracing` Integration in JavaScript Browser. It's a helper that tells the Integration for how long it should keep the `IdleTransaction` alive. An activity can be pushed and popped. Once all activities of an `IdleTransaction` have been popped, the `IdleTransaction` will be sent to Sentry.
268
+
221
269
**Manual Transactions**
222
270
223
271
To manually instrument certain regions of your code, you can create a [transaction]({%- link _documentation/performance/performance-glossary.md -%}#transaction) to capture them.
272
+
This is both valid for JavaScript Browser and Node and works besides the `Tracing` integration.
224
273
225
274
The following example creates a transaction for a scope that contains an expensive operation (for example, `process_item`), and sends the result to Sentry:
0 commit comments