|
1 | 1 | ---
|
2 | 2 | title: Performance Monitoring
|
3 | 3 | sidebar_order: 20
|
4 |
| -description: "Learn more about how to configure our Performance integrations to get the best experience out of it." |
| 4 | +description: "Learn how to enable performance monitoring in your app." |
5 | 5 | redirect_from:
|
6 | 6 | - /platforms/javascript/performance/apm-to-tracing/
|
7 | 7 | ---
|
@@ -41,28 +41,44 @@ Once you've installed the package, there are two ways to enable tracing in your
|
41 | 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.
|
42 | 42 |
|
43 | 43 | ```javascript {tabTitle: ESM}
|
44 |
| -// Substitude `@sentry/browser` for the integration you're using (if applicable) |
| 44 | +// If you're using one of our integration packages, like `@sentry/react` or |
| 45 | +// `@sentry/angular`, substitute its name for `@sentry/browser` here |
45 | 46 | import * as Sentry from "@sentry/browser";
|
46 | 47 |
|
47 |
| -// Pull in the additional tracing integration |
| 48 | +// If taking advantage of automatic instrumentation (highly recommended) |
48 | 49 | import { Integrations as TracingIntegrations } from "@sentry/tracing";
|
| 50 | +// Or, if only doing manual tracing |
| 51 | +// import * as _ from "@sentry/tracing" |
| 52 | +// Note: You MUST import the package in some way for tracing to work |
49 | 53 |
|
50 | 54 | Sentry.init({
|
51 | 55 | dsn: "___PUBLIC_DSN___",
|
| 56 | + |
| 57 | + // This enables automatic instrumentation (highly recommeneded), but is not |
| 58 | + // necessary for purely manual usage |
52 | 59 | integrations: [new TracingIntegrations.BrowserTracing()],
|
53 | 60 |
|
54 |
| - // Be sure to lower this in production, or use tracesSampler for finer control |
55 |
| - tracesSampleRate: 1.0, |
| 61 | + // To set a uniform sample rate |
| 62 | + tracesSampleRate: 0.2 |
| 63 | + |
| 64 | + // Alternatively, to control sampling dynamically |
| 65 | + tracesSampler: samplingContext => { ... } |
56 | 66 | });
|
57 | 67 | ```
|
58 | 68 |
|
59 | 69 | ```javascript {tabTitle: CDN}
|
60 | 70 | Sentry.init({
|
61 | 71 | dsn: "___PUBLIC_DSN___",
|
| 72 | +
|
| 73 | + // This enables automatic instrumentation (highly recommeneded), but is not |
| 74 | + // necessary for purely manual usage |
62 | 75 | integrations: [new Sentry.Integrations.BrowserTracing()],
|
63 | 76 |
|
64 |
| - // Be sure to lower this in production, or use tracesSampler for finer control |
65 |
| - tracesSampleRate: 1.0, |
| 77 | + // To set a uniform sample rate |
| 78 | + tracesSampleRate: 0.2 |
| 79 | +
|
| 80 | + // Alternatively, to control sampling dynamically |
| 81 | + tracesSampler: samplingContext => { ... } |
66 | 82 | });
|
67 | 83 | ```
|
68 | 84 |
|
|
0 commit comments