Skip to content

Commit 7611035

Browse files
authored
Update Android continuous profiling instructions and options (#13219)
* updated Android continuous profiling instructions and options * Added deprecation notes for transaction-based profiling
1 parent 5b1463f commit 7611035

File tree

3 files changed

+226
-130
lines changed

3 files changed

+226
-130
lines changed

docs/platforms/android/configuration/options.mdx

+26-24
Original file line numberDiff line numberDiff line change
@@ -301,54 +301,56 @@ Set this boolean to `false` to disable tracing for `OPTIONS` requests. This opti
301301

302302
</ConfigKey>
303303

304-
## Profiling Options
304+
## UI Profiling Options
305305

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

308-
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>.
308+
UI Profiling requires SDK versions `8.7.0` or higher. Lower versions can use the <PlatformLink to="/configuration/options/#transaction-based-profiling-options">transaction-based profiling</PlatformLink>.
309309

310-
</ConfigKey>
310+
</Alert>
311311

312-
<ConfigKey name="profiles-sampler">
312+
<ConfigKey name="profile-session-sample-rate">
313313

314-
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>.
314+
A number between `0` and `1`, controlling the percentage chance that the session will be profiled. `0` represents 0% while `1` represents 100%. The default is null (disabled).
315315

316316
</ConfigKey>
317317

318-
<ConfigKey name="enable-app-start-profiling">
318+
<ConfigKey name="profile-lifecycle">
319319

320-
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.
320+
Whether the UI profiling lifecycle is controlled manually or based on the trace lifecycle. Possible values are:
321+
322+
- `manual`: **default** Profiler must be started and stopped through `Sentry.startProfiler()` and `Sentry.stopProfiler()` APIs
323+
- `trace`: Profiler is started and stopped automatically whenever a sampled trace starts or finishes
321324

322325
</ConfigKey>
323326

324-
## Continuous Profiling Options
327+
<ConfigKey name="start-profiler-on-app-start">
325328

326-
<Alert>
329+
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.
327330

328-
This feature is experimental and may have bugs.
331+
- 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
332+
- 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
329333

330-
</Alert>
334+
</ConfigKey>
331335

332-
<ConfigKey name="profile-session-sample-rate">
336+
## Transaction-Based Profiling Options
333337

334-
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>.
338+
This mode will eventually be deprecated, and it's recommended to upgrade to <PlatformLink to="/configuration/options/#ui-profiling-options">UI Profiling</PlatformLink>. The same behaviour, without the 30 seconds limitation, can be achieved with the `trace` <PlatformLink to="/configuration/options/#profile-lifecycle">profile lifecycle</PlatformLink> option. In order to upgrade to UI Profiling, you also need to remove the transaction-based options from your configuration.
335339

336-
</ConfigKey>
340+
<ConfigKey name="profiles-sample-rate">
337341

338-
<ConfigKey name="profile-lifecycle">
342+
A number between `0` and `1`, controlling the percentage chance that 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.
339343

340-
Whether the profiling lifecycle is controlled manually or based on the trace lifecycle. Possible values are:
344+
</ConfigKey>
341345

342-
- `manual`: **default** Profiler must be started and stopped through `Sentry.startProfiler()` and `Sentry.stopProfiler()` APIs
343-
- `trace`: Profiler is started and stopped automatically whenever a sampled trace starts and finishes
346+
<ConfigKey name="profiles-sampler">
344347

345-
</ConfigKey>
348+
A function responsible for determining the percentage chance that 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.
346349

347-
<ConfigKey name="start-profiler-on-app-start">
350+
</ConfigKey>
348351

349-
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.
352+
<ConfigKey name="enable-app-start-profiling">
350353

351-
- 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
352-
- 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
354+
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.
353355

354356
</ConfigKey>

docs/platforms/android/index.mdx

+5-16
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ Select which Sentry features you'd like to install in addition to Error Monitori
3030
options={[
3131
'error-monitoring',
3232
'performance',
33-
{
34-
id: 'profiling',
35-
checked: false
36-
},
33+
'profiling',
3734
'session-replay'
3835
]}
3936
/>
@@ -83,13 +80,13 @@ Configuration is done via the application `AndroidManifest.xml`. Here's an examp
8380
<meta-data android:name="io.sentry.send-default-pii" android:value="true" />
8481
<!-- Enable the performance API by setting a sample-rate, adjust in production env -->
8582
<meta-data android:name="io.sentry.traces.sample-rate" android:value="1.0" />
86-
<!-- Enable profiling, adjust in production env. See https://docs.sentry.io/platforms/android/profiling for more info -->
83+
<!-- Enable profiling, adjust in production env. This is evaluated only once per session -->
8784
<meta-data android:name="io.sentry.traces.profiling.session-sample-rate" android:value="1.0" />
88-
<!-- Set profiling lifecycle, can be `manual` or `trace` -->
89-
<meta-data android:name="io.sentry.traces.profiling.lifecycle" android:value="manual" />
85+
<!-- 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) -->
86+
<meta-data android:name="io.sentry.traces.profiling.lifecycle" android:value="trace" />
9087
<!-- Enable profiling on app start -->
9188
<meta-data android:name="io.sentry.traces.profiling.start-on-app-start" android:value="true" />
92-
<!-- record session replays for 100% of errors and 10% of sessions -->
89+
<!-- Record session replays for 100% of errors and 10% of sessions -->
9390
<meta-data android:name="io.sentry.session-replay.on-error-sample-rate" android:value="1.0" />
9491
<meta-data android:name="io.sentry.session-replay.session-sample-rate" android:value="0.1" />
9592
</application>
@@ -108,15 +105,11 @@ import io.sentry.Sentry;
108105
public class MyActivity extends AppCompatActivity {
109106
protected void onCreate(Bundle savedInstanceState) {
110107
super.onCreate(savedInstanceState);
111-
// Any code running after this line will be
112-
//profiled until Sentry.stopProfiler() is called.
113-
Sentry.startProfiler();
114108
try {
115109
throw new Exception("This is a test.");
116110
} catch (Exception e) {
117111
Sentry.captureException(e);
118112
}
119-
Sentry.stopProfiler();
120113
}
121114
}
122115
```
@@ -129,15 +122,11 @@ import io.sentry.Sentry
129122
class MyActivity : AppCompatActivity() {
130123
override fun onCreate(savedInstanceState: Bundle?) {
131124
super.onCreate(savedInstanceState)
132-
// Any code running after this line will be
133-
//profiled until Sentry.stopProfiler() is called.
134-
Sentry.startProfiler()
135125
try {
136126
throw Exception("This is a test.")
137127
} catch (e: Exception) {
138128
Sentry.captureException(e)
139129
}
140-
Sentry.stopProfiler()
141130
}
142131
}
143132
```

0 commit comments

Comments
 (0)