Skip to content

Commit f430e22

Browse files
committed
add enablement intro section
1 parent 87cc9f6 commit f430e22

File tree

1 file changed

+39
-0
lines changed
  • src/platforms/javascript/common/performance

1 file changed

+39
-0
lines changed

src/platforms/javascript/common/performance/index.mdx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,39 @@ redirect_from:
66
- /platforms/javascript/performance/apm-to-tracing/
77
---
88

9+
Sentry allows you to monitor the performance of your application, showing you how latency in one service may affect another service, and letting you pinpoint exactly which parts of a given operation may be responsible. To do this, it captures distributed traces consisting of transactions and spans, which measure individual services and individual operations within those services, respectively. You can learn more about this model in our [Distributed Tracing](/product/performance/distributed-tracing/) docs.
10+
11+
Once tracing is enabled, certain types of operations will be measured automatically, and you can also choose to manually measure any operation you like. To learn more, see [Capturing Transactions Automatically](/platforms/javascript/performance/automatic/) and [Capturing Transactions Manually](/platforms/javascript/performance/manual/).
12+
13+
## Enabling Tracing
14+
15+
The first step is to install the tracing package, if you haven't done so already:
16+
17+
```bash {tabTitle: ESM}
18+
# Using yarn
19+
$ yarn add @sentry/tracing
20+
21+
# Using npm
22+
$ npm install @sentry/tracing
23+
```
24+
25+
```html {tabTitle: CDN}
26+
<script
27+
<!--
28+
Note that `bundle.tracing.min.js` contains both `@sentry/browser` AND
29+
`@sentry/tracing`, and should therefore be used in place of
30+
`@sentry/browser`'s bundle rathern than in addition to it.
31+
-->
32+
src="https://browser.sentry-cdn.com/{{ packages.version('sentry.javascript.browser') }}/bundle.tracing.min.js"
33+
integrity="sha384-{{ packages.checksum('sentry.javascript.browser', 'bundle.tracing.min.js', 'sha384-base64') }}"
34+
crossorigin="anonymous"
35+
></script>
36+
```
37+
38+
Once you've installed the package, there are two ways to enable tracing in your app:
39+
40+
- Set a uniform sample rate for all transactions, by setting the `tracesSampleRate` option in your SDK config to a number between `0` and `1`. (For example, to send 20% of transactions, set `tracesSampleRate` to `0.2`.)
41+
- Control the sample rate dynamically, based on the transaction itself and the context in which it's captured, by providing a function to the `tracesSampler` config option.
942
1043
```javascript {tabTitle: ESM}
1144
// Substitude `@sentry/browser` for the integration you're using (if applicable)
@@ -33,11 +66,17 @@ Sentry.init({
3366
});
3467
```
3568

69+
If either of these options is set, tracing will be enabled in your app. (They are meant to be mutually exclusive, but if you do set both, `tracesSampler` will take precedence.) You can learn more about how they work in [Sampling Transactions](/platforms/javascript/performance/sampling/).
3670

71+
<Alert level="info" title="Note"><markdown>
3772
73+
When you first enable tracing, the easiest thing to do to test it is to set `tracesSampleRate` to `1.0`, because that guarantees that every transaction will be sent to Sentry for you to see.
3874
75+
Once you're done with testing, however, we recommend that you either **lower your `tracesSampleRate` value, or switch to using `tracesSampler` to dynamically sample and filter your transactions**.
3976
77+
Without sampling, our atomatic instrumenation will send a transaction any time any user loads any page or navigates anywhere in your app. That's a lot of transactions! Sampling allows you to get representative data without overwhelming either your system or your Sentry transaction quota.
4078
79+
</markdown></Alert>
4180
4281
### Connecting Backend and Frontend Transactions
4382

0 commit comments

Comments
 (0)