Skip to content
Merged
48 changes: 27 additions & 21 deletions docs/platforms/android/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -303,52 +303,58 @@ Set this boolean to `false` to disable tracing for `OPTIONS` requests. This opti

## Profiling Options

<ConfigKey name="profiles-sample-rate">
<Alert title="Note">

Profiling requires SDK versions 8.7.0 or higher. Lower versions can use the legacy 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>.
</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).

</ConfigKey>

<ConfigKey name="profiles-sampler">
<ConfigKey name="profile-lifecycle">

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>.
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.startProfiler()` and `Sentry.stopProfiler()` APIs
- `trace`: Profiler is started and stopped automatically whenever a sampled trace starts and finishes

</ConfigKey>

<ConfigKey name="enable-app-start-profiling">
<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="profiles-sample-rate" /> or <PlatformIdentifier name="profiles-sampler" /> must be defined.
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 stopProfiler 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>

## Continuous Profiling Options
## Legacy Profiling Options

<Alert>
<Alert title="Note">

This feature is experimental and may have bugs.
SDK versions lower than 8.6.0 may use the legacy profiling using the following options.

</Alert>

<ConfigKey name="profile-session-sample-rate">
<ConfigKey name="profiles-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>.
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. Setting this option will enable the legacy profiler.

</ConfigKey>

<ConfigKey name="profile-lifecycle">

Whether the profiling lifecycle is controlled manually or based on the trace lifecycle. Possible values are:
<ConfigKey name="profiles-sampler">

- `manual`: **default** Profiler must be started and stopped through `Sentry.startProfiler()` and `Sentry.stopProfiler()` APIs
- `trace`: Profiler is started and stopped automatically whenever a sampled trace starts and finishes
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. Setting this option will enable the legacy profiler.

</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.
<ConfigKey name="enable-app-start-profiling">

- If profileLifecycle is set to `manual`: profiling is started automatically on startup and stopProfiler 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
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.

</ConfigKey>
23 changes: 10 additions & 13 deletions docs/platforms/android/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ Select which Sentry features you'd like to install in addition to Error Monitori
options={[
'error-monitoring',
'performance',
{
id: 'profiling',
checked: false
},
'profiling',
'session-replay'
]}
/>
Expand Down Expand Up @@ -83,10 +80,10 @@ Configuration is done via the application `AndroidManifest.xml`. Here's an examp
<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 -->
<meta-data android:name="io.sentry.traces.sample-rate" android:value="1.0" />
<!-- Enable profiling, adjust in production env. See https://docs.sentry.io/platforms/android/profiling for more info -->
<!-- Enable profiling, adjust in production env. This is evaluated only once per session -->
<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" />
<!-- Set profiling lifecycle, can be `manual` (controlled through `Sentry.startProfiler()` and `Sentry.stopProfiler()`) or `trace` (automatically starts and stop a profile whenever a sampled trace starts and finishes) -->
<meta-data android:name="io.sentry.traces.profiling.lifecycle" android:value="trace" />
<!-- Enable profiling on app start -->
<meta-data android:name="io.sentry.traces.profiling.start-on-app-start" android:value="true" />
<!-- record session replays for 100% of errors and 10% of sessions -->
Expand All @@ -99,7 +96,7 @@ Configuration is done via the application `AndroidManifest.xml`. Here's an examp

Verify that your app is sending events to Sentry by adding the following snippet, which includes an intentional error. You should see the error reported in Sentry within a few minutes.

```java
```java {"onboardingOptions": {"profiling": "9-10, 16-17"}}
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import java.lang.Exception;
Expand All @@ -108,35 +105,35 @@ 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.
// Any code running after this line will be profiled, if lifecycle is set to `manual`.
Sentry.startProfiler();
try {
throw new Exception("This is a test.");
} catch (Exception e) {
Sentry.captureException(e);
}
// Stop profiling, if lifecycle is set to `manual`. This call is optional. If you don't stop the profiler, it will keep profiling your application until the process exits or `Sentry.stopProfiler()` is called.
Sentry.stopProfiler();
}
}
```

```kotlin
```kotlin {"onboardingOptions": {"profiling": "8-9, 15-16"}}
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
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.
// Any code running after this line will be profiled, if lifecycle is set to `manual`.
Sentry.startProfiler()
try {
throw Exception("This is a test.")
} catch (e: Exception) {
Sentry.captureException(e)
}
// Stop profiling, if lifecycle is set to `manual`. This call is optional. If you don't stop the profiler, it will keep profiling your application until the process exits or `Sentry.stopProfiler()` is called.
Sentry.stopProfiler()
}
}
Expand Down
Loading