Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
32 changes: 32 additions & 0 deletions docs/platforms/android/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
24 changes: 15 additions & 9 deletions docs/platforms/android/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +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, 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 @@ -98,15 +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.stopProfiler() is called.
Sentry.startProfiler();
// 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.stopProfiler();
Sentry.stopProfileSession();
}
}
```
Expand All @@ -119,15 +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.stopProfiler() is called.
Sentry.startProfiler()
// 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.stopProfiler()
Sentry.stopProfileSession()
}
}
```
Expand Down
6 changes: 3 additions & 3 deletions docs/platforms/android/profiling/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ _(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.startProfiler` and `Sentry.stopProfiler`. You can also start a profile at app launch by setting `SentryOptions.enableAppStartProfiling = true` in your call to `SentryAndroid.init`.
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 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.
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.

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.
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.