Skip to content

Commit 95b7721

Browse files
s1gr1dphilipphofmann
authored andcommitted
docs(profiling): Add docs for UI profiling (Browser JS) (#15611)
## DESCRIBE YOUR PR Adds docs for the new UI Profiling APIs in the browser. part of getsentry/sentry-javascript#17279 ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [ ] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs)
1 parent 9dcdb3e commit 95b7721

File tree

19 files changed

+113
-75
lines changed

19 files changed

+113
-75
lines changed

develop-docs/sdk/telemetry/profiles/continuous-profiling-api.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Those are the two modes:
7474
- **`'trace'`**: **This mode requires tracing to be enabled.** The profiler starts automatically when there is at least one active root span and stops when there are no active root spans (letting the current chunk completely finish).
7575
- Profiling respects **both** `profile_session_sample_rate` and the tracing sampling configuration (`traces_sample_rate` or `traces_sampler`).
7676
- `profile_session_sample_rate` is checked first. If the session is not sampled, no profiling will occur.
77-
- If the session is sampled, `traces_sample_rate` / `traces_sampler` is evaluated for each root span to determine if it should be profiled.
77+
- Only if a root span is sampled (this is based on `traces_sample_rate` / `traces_sampler`), profiling will start. Therefore, profile sampling is re-evaluated for each root span.
7878
- The profiler runs as long as there is at least one **sampled** root span. If multiple root spans overlap, profiling continues until the last sampled root span finishes.
7979

8080
<Alert level="warning">

docs/platforms/android/profiling/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The transaction-based profiler is available on SDK versions `6.16.0` and higher
1919

2020
## Enabling UI Profiling
2121

22-
UI Profiling supports two modes - `manual` and `trace`. The two modes are mutually exclusive, and cannot be used at the same time.
22+
UI Profiling supports two modes: `manual` and `trace`. These modes are mutually exclusive and cannot be used at the same time.
2323

2424
In `manual` mode, the profiling data collection can be managed via calls to `Sentry.profiler.startProfiler` and `Sentry.profiler.stopProfiler`. You are entirely in the in control of when the profiler runs.
2525

docs/platforms/java/common/profiling/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ implementation 'io.sentry:sentry-async-profiler:{{@inject packages.version('sent
3737

3838
## Enabling Continuous Profiling
3939

40-
Continuous profiling supports two modes - `manual` and `trace`. The two modes are mutually exclusive, and cannot be used at the same time.
40+
Continuous Profiling supports two modes: `manual` and `trace`. These modes are mutually exclusive and cannot be used at the same time.
4141

4242
In `manual` mode, the profiling data collection can be managed via calls to `Sentry.startProfiler()` and `Sentry.stopProfiler()`. You are entirely in control of when the profiler runs.
4343

@@ -61,5 +61,5 @@ Continuous profiling for Java is currently supported on:
6161
- macOS
6262
- Linux
6363

64-
The profiler uses [async-profiler](https://github.com/async-profiler/async-profiler) under the hood to collect profiling data.
64+
The profiler uses [async-profiler](https://github.com/async-profiler/async-profiler) under the hood to collect profiling data.
6565

docs/platforms/javascript/common/configuration/options.mdx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,12 +548,41 @@ The sample rate for replays that are recorded when an error happens. This type o
548548

549549
## Profiling Options
550550

551+
<SdkOption name="profileSessionSampleRate" type='number' availableSince="10.27.0">
552+
553+
A number between `0` and `1` that sets the percentage of how many sessions should have profiling enabled. `1.0` enables profiling in every session, `0.5` enables profiling for 50% of the sessions, and `0` enables it for none. The sampling decision is made once at the beginning of a session. This option is required to enable profiling.
554+
555+
<PlatformCategorySection categorySupported={["server", "serverless"]}>
556+
In a server environment, a profiling session starts when the Sentry SDK is initialized and stops when the service terminates.
557+
Therefore, the sampling decision is re-evaluated on service restart or redeployment.
558+
</PlatformCategorySection>
559+
560+
<PlatformCategorySection supported={['browser']}>
561+
In a browser environment, a profiling session corresponds to a user session. A user session starts with a
562+
new SDK initialization on page load and ends when the browser tab is closed.
563+
</PlatformCategorySection>
564+
</SdkOption>
565+
566+
567+
<SdkOption name="profileLifecycle" type='"trace" | "manual"' defaultValue='"manual"' availableSince="10.27.0">
568+
569+
Determines how profiling sessions are controlled. It has two modes:
570+
571+
- `'manual'` (default): You control when profiling starts and stops using the `startProfiler()` and `stopProfiler()` functions. In this mode, profile sampling is only affected by `profileSessionSampleRate`. Read more about these functions in the <PlatformLink to="/profiling">profiling API documentation</PlatformLink>.
572+
- `'trace'`: Profiling starts and stops automatically with transactions, as long as tracing is enabled. The profiler runs as long as there is at least one sampled transaction. In this mode, profiling is affected by both `profileSessionSampleRate` and your tracing sample rate (`tracesSampleRate` or `tracesSampler`).
573+
574+
</SdkOption>
575+
576+
551577
<SdkOption name="profilesSampleRate" type='number'>
552578

553-
A number between `0` and `1`, controlling the percentage chance a given sampled transaction will be profiled. (`0` represents 0% while `1` represents 100%.) Applies equally to all transactions created in the app. This is relative to the tracing sample rate - e.g. `0.5` means 50% of sampled transactions will be profiled.
579+
**Deprecated:** Use `profileSessionSampleRate` instead to configure continuous profiling from version 10.27.0 onwards.
580+
581+
A number between `0` and `1`, controlling the percentage chance a given sampled transaction will be profiled. (`0` represents 0% while `1` represents 100%.) Applies equally to all transactions created in the app. This is relative to the tracing sample rate - e.g. `0.5` means 50% of sampled transactions will be profiled.
554582

555583
</SdkOption>
556584

585+
557586
<PlatformSection supported={["javascript.cordova", "javascript.capacitor"]}>
558587

559588
## Experimental Options

docs/platforms/javascript/guides/astro/index.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,8 @@ Sentry.init({
187187
// ___PRODUCT_OPTION_END___ performance
188188
// ___PRODUCT_OPTION_START___ profiling
189189

190-
// Set sampling rate for profiling
191-
// This is relative to tracesSampleRate
192-
profilesSampleRate: 1.0,
190+
// Define how many user sessions have profiling enabled.
191+
profileSessionSampleRate: 1.0,
193192
// ___PRODUCT_OPTION_END___ profiling
194193
});
195194
```

docs/platforms/python/profiling/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Continuous profiling is available starting in SDK version `2.24.1`.
2020

2121
</Alert>
2222

23-
Continuous profiling supports two modes - `manual` and `trace`. The two modes are mutually exclusive, and cannot be used at the same time.
23+
Continuous Profiling supports two modes: `manual` and `trace`. These modes are mutually exclusive and cannot be used at the same time.
2424

2525
In `manual` mode, the profiling data collection can be managed via calls to `sentry_sdk.profiler.start_profiler` and `sentry_sdk.profiler.stop_profiler`. You are entirely in control of when the profiler runs.
2626

docs/product/explore/profiling/getting-started.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sidebar_order: 2
44
description: "Get started with Profiling, which allows you to see code-level profiling information for your Sentry apps."
55
---
66

7-
Continuous Profiling and UI Profiling are the latest iteration of Sentry’s profiling capabilities, but they are currently only supported in select SDKs as described below.
7+
Continuous Profiling and UI Profiling are the latest iteration of Sentry’s profiling capabilities, but they are currently only supported in select SDKs as described below.
88

99
Other platforms are supported via the prior transaction-based Profiling product, but these will not benefit from new capabilities introduced by Continuous and UI Profiling (direct start/stop control over the profile lifecycle and removal of duration limits). For more information on the differences between transaction-based Profiling and Continuous/UI Profiling, read [this documentation](/product/explore/profiling/transaction-vs-continuous-profiling).
1010

@@ -30,10 +30,11 @@ Continuous Profiling can be used both independently and as a complement to the t
3030

3131
<Alert>
3232

33-
UI Profiling can be used both independently and as a complement to the tracing product. Support for Browser JavaScript is coming soon.
33+
UI Profiling can be used both independently and as a complement to the tracing product.
3434

3535
</Alert>
3636

37+
- [Browser JavaScript](/platforms/javascript/profiling/) [beta] (since version `10.27.0`)
3738
- Mobile
3839
- [Android](/platforms/android/profiling/#continuous-profiling)
3940
- [iOS and macOS](/platforms/apple/guides/ios/profiling/#continuous-profiling)

platform-includes/profiling/automatic-instrumentation-setup/_default.mdx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ Sentry.init({
1616
// Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled
1717
tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
1818

19-
// Set profilesSampleRate to 1.0 to profile every transaction.
20-
// Since profilesSampleRate is relative to tracesSampleRate,
21-
// the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
22-
// For example, a tracesSampleRate of 0.5 and profilesSampleRate of 0.5 would
23-
// result in 25% of transactions being profiled (0.5*0.5=0.25)
24-
profilesSampleRate: 1.0,
19+
// Set profileSessionSampleRate to 1.0 to profile during every session.
20+
// The decision, whether to profile or not, is made once per session (when the SDK is initialized).
21+
profileSessionSampleRate: 1.0,
2522
});
2623
```

platform-includes/profiling/automatic-instrumentation-setup/javascript.angular.mdx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ Sentry.init({
1616
// Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled
1717
tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
1818

19-
// Set profilesSampleRate to 1.0 to profile every transaction.
20-
// Since profilesSampleRate is relative to tracesSampleRate,
21-
// the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
22-
// For example, a tracesSampleRate of 0.5 and profilesSampleRate of 0.5 would
23-
// result in 25% of transactions being profiled (0.5*0.5=0.25)
24-
profilesSampleRate: 1.0,
19+
// Set profileSessionSampleRate to 1.0 to profile during every session.
20+
// The decision, whether to profile or not, is made once per session (when the SDK is initialized).
21+
profileSessionSampleRate: 1.0,
2522
});
2623
```

platform-includes/profiling/automatic-instrumentation-setup/javascript.astro.mdx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ Sentry.init({
1515
// Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled
1616
tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
1717

18-
// Set profilesSampleRate to 1.0 to profile every transaction.
19-
// Since profilesSampleRate is relative to tracesSampleRate,
20-
// the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
21-
// For example, a tracesSampleRate of 0.5 and profilesSampleRate of 0.5 would
22-
// result in 25% of transactions being profiled (0.5*0.5=0.25)
23-
profilesSampleRate: 1.0,
18+
// Set profileSessionSampleRate to 1.0 to profile during every session.
19+
// The decision, whether to profile or not, is made once per session (when the SDK is initialized).
20+
profileSessionSampleRate: 1.0,
2421
});
2522
```

0 commit comments

Comments
 (0)