Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions docs/platforms/android/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,13 @@ Set this boolean to `false` to disable tracing for `OPTIONS` requests. This opti

<ConfigKey name="profiles-sample-rate">

A number between `0` and `1`, controlling the percentage chance a given profile will be sent to Sentry. (`0` represents 0% while `1` represents 100%.) Applies only to sampled transactions created in the app. Either this or <PlatformIdentifier name="profiles-sampler" /> must be defined to enable profiling.
A number between `0` and `1`, controlling the percentage chance a given profile will be sent to Sentry. (`0` represents 0% while `1` represents 100%.) Applies only to sampled transactions created in the app. Either this or <PlatformIdentifier name="profiles-sampler" /> must be defined to enable transaction profiling. Don't set it if you want to use <PlatformLink to="/profiling/#continuous-profiling">Continuous Profiling</PlatformLink>.

</ConfigKey>

<ConfigKey name="profiles-sampler">

A function responsible for determining the percentage chance a given profile will be sent to Sentry. It will automatically be passed information about the transaction and the context in which it's being created, and must return a number between `0` (0% chance of being sent) and `1` (100% chance of being sent). Can also be used for filtering profiles, by returning 0 for those that are unwanted. Either this or <PlatformIdentifier name="profiles-sample-rate" /> must be defined to enable profiling.
A function responsible for determining the percentage chance a given profile will be sent to Sentry. It will automatically be passed information about the transaction and the context in which it's being created, and must return a number between `0` (0% chance of being sent) and `1` (100% chance of being sent). Can also be used for filtering profiles, by returning 0 for those that are unwanted. Either this or <PlatformIdentifier name="profiles-sample-rate" /> must be defined to enable transaction profiling. Don't set it if you want to use <PlatformLink to="/profiling/#continuous-profiling">Continuous Profiling</PlatformLink>.

</ConfigKey>

Expand All @@ -320,3 +320,35 @@ A function responsible for determining the percentage chance a given profile wil
A boolean value that determines whether the app start process will be profiled. When true, the startup process, including ContentProviders, Application and first Activity creation, will be profiled. Note that <PlatformIdentifier name="profiles-sample-rate" /> or <PlatformIdentifier name="profiles-sampler" /> must be defined.

</ConfigKey>

## Continuous Profiling Options

<Alert>

This feature is experimental and may have bugs.

</Alert>

<ConfigKey name="profile-session-sample-rate">

A number between `0` and `1`, controlling the percentage chance the session will be profiled. `0` represents 0% while `1` represents 100%. The default is null (disabled). <PlatformIdentifier name="profiles-sampler" /> and <PlatformIdentifier name="profiles-sample-rate" /> must not be set to enable <PlatformLink to="/profiling/#continuous-profiling">Continuous Profiling</PlatformLink>.

</ConfigKey>

<ConfigKey name="profile-lifecycle">

Whether the profiling lifecycle is controlled manually or based on the trace lifecycle. Possible values are:

- `manual`: **default** Profiler must be started and stopped through `Sentry.startProfileSession()` and `Sentry.stopProfileSession()` APIs
- `trace`: Profiler is started and stopped automatically whenever a sampled trace starts and finishes

</ConfigKey>

<ConfigKey name="start-profiler-on-app-start">

A boolean value that determines whether the app start process will be profiled. When true, the startup process, including ContentProviders, Application and first Activity creation, will be profiled. Note that <PlatformIdentifier name="profile-session-sample-rate" /> must be defined.

- If profileLifecycle is set to `manual`: profiling is started automatically on startup and stopProfileSession must be called manually whenever the app startup is deemed to be completed
- If profileLifecycle is set to `trace`: profiling is started automatically on startup, and will automatically be stopped when the root span that is associated with app startup ends

</ConfigKey>
18 changes: 15 additions & 3 deletions docs/platforms/android/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,14 @@ Configuration is done via the application `AndroidManifest.xml`. Here's an examp
<meta-data android:name="io.sentry.dsn" android:value="___PUBLIC_DSN___" />
<!-- Add data like request headers, user ip address and device name, see https://docs.sentry.io/platforms/android/data-management/data-collected/ for more info -->
<meta-data android:name="io.sentry.send-default-pii" android:value="true" />
<!-- enable the performance API by setting a sample-rate, adjust in production env -->
<!-- Enable the performance API by setting a sample-rate, adjust in production env -->
<meta-data android:name="io.sentry.traces.sample-rate" android:value="1.0" />
<!-- enable profiling when starting transactions, adjust in production env -->
<meta-data android:name="io.sentry.traces.profiling.sample-rate" android:value="1.0" />
<!-- Enable profiling, adjust in production env -->
<meta-data android:name="io.sentry.traces.profiling.session-sample-rate" android:value="1.0" />
<!-- Set profiling lifecycle, can be `manual` or `trace` -->
<meta-data android:name="io.sentry.traces.profiling.lifecycle" android:value="manual" />
<!-- Enable profiling on app start -->
<meta-data android:name="io.sentry.traces.profiling.start-on-app-start" android:value="true" />
</application>
```

Expand All @@ -100,11 +104,15 @@ import io.sentry.Sentry;
public class MyActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Any code running after this line will be
//profiled until Sentry.stopProfileSession() is called.
Sentry.startProfileSession();
try {
throw new Exception("This is a test.");
} catch (Exception e) {
Sentry.captureException(e);
}
Sentry.stopProfileSession();
}
}
```
Expand All @@ -117,11 +125,15 @@ import io.sentry.Sentry
class MyActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Any code running after this line will be
//profiled until Sentry.stopProfileSession() is called.
Sentry.startProfileSession()
try {
throw Exception("This is a test.")
} catch (e: Exception) {
Sentry.captureException(e)
}
Sentry.stopProfileSession()
}
}
```
Expand Down
20 changes: 20 additions & 0 deletions docs/platforms/android/profiling/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,23 @@ The SDK won't run app start profiling the very first time the app runs, as the S
The SDK will set the `isForNextAppStart` flag in `TransactionContext` if app start profiling is enabled.

</Alert>

## Continuous Profiling

<Alert>

This feature is experimental and may have bugs.

</Alert>

_(New in version 8.0.0)_

The current profiling implementation stops the profiler automatically after 30 seconds (unless you manually stop it earlier). Naturally, this limitation makes it difficult to get full coverage of your app's execution. We now offer an experimental continuous mode, where profiling data is periodically uploaded while running, with no limit to how long the profiler may run.

Previously, profiles only ran in tandem with performance transactions that were started either automatically or manually with `Sentry.startTransaction`. Now, you can start and stop the profiler directly with `Sentry.startProfileSession` and `Sentry.stopProfileSession`. You can also start a profile at app launch by setting `SentryOptions.startProfilerOnAppStart = true` in your call to `SentryAndroid.init`.

Continuous profiling mode is disabled by default, requiring only the `SentryOptions.profileSessionSampleRate` option to be set when you start the SDK to opt in. If you had previously set `SentryOptions.profilesSampleRate` or `SentryOptions.profilesSampler` to use transaction-based profiling, then remove those lines of code from your configuration.

There are two ways to start the profiler: manually, calling `Sentry.startProfileSession` and `Sentry.stopProfileSession` to start and stop the profiler, or automatically whenever a sampled trace starts and finishes. The latter behaviour is very similar to the current profiling implementation. You can control this behaviour setting `SentryOptions.profileLifecycle` to `manual` or `trace` in your call to `SentryAndroid.init`.

Continuous profiling has implications for your org's billing structure. This feature is only available for subscription plans that enrolled after June 5, 2024.
2 changes: 1 addition & 1 deletion docs/platforms/apple/common/profiling/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ Previously, profiles only ran in tandem with performance transactions that were

Continuous profiling mode is enabled by default, requiring no changes to `SentryOptions` when you start the SDK to opt in. If you had previously set `SentryOptions.profilesSampleRate` or `SentryOptions.profilesSampler` to use transaction-based profiling, then remove those lines of code from your configuration.

These new APIs do not offer any sampling functionality—every call to start the profiler will start it, and the same goes for launch profiles if you've configured that. If you are interested in reducing the amount of profiles that run, you must take care to do it at the callsites.
These new APIs do not offer any sampling functionality—every call to start the profiler will start it, and the same goes for launch profiles if you've configured that. If you are interested in reducing the amount of profiles that run, you must take care to do it at the call sites.

Continuous profiling has implications for your org's billing structure. This feature is only available for subscription plans that enrolled after June 5, 2024.
1 change: 1 addition & 0 deletions docs/product/explore/profiling/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Profiling depends on Sentry's performance monitoring product being enabled befor
<Include name="feature-stage-beta.mdx" />

- Mobile
- [Android](/platforms/android/profiling/#continuous-profiling)
- [iOS and macOS](/platforms/apple/guides/ios/profiling/#continuous-profiling)
- Standalone and server apps
- [Node.js](/platforms/javascript/guides/node/profiling/#enable-continuous-profiling)
Expand Down