Skip to content

Commit b706745

Browse files
committed
updated Android continuous profiling instructions and options
1 parent 28ad795 commit b706745

File tree

3 files changed

+228
-122
lines changed

3 files changed

+228
-122
lines changed

docs/platforms/android/configuration/options.mdx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -303,52 +303,52 @@ Set this boolean to `false` to disable tracing for `OPTIONS` requests. This opti
303303

304304
## Profiling Options
305305

306-
<ConfigKey name="profiles-sample-rate">
306+
<ConfigKey name="profile-session-sample-rate">
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+
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).
309309

310310
</ConfigKey>
311311

312-
<ConfigKey name="profiles-sampler">
312+
<ConfigKey name="profile-lifecycle">
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+
Whether the profiling lifecycle is controlled manually or based on the trace lifecycle. Possible values are:
315+
316+
- `manual`: **default** Profiler must be started and stopped through `Sentry.startProfiler()` and `Sentry.stopProfiler()` APIs
317+
- `trace`: Profiler is started and stopped automatically whenever a sampled trace starts and finishes
315318

316319
</ConfigKey>
317320

318-
<ConfigKey name="enable-app-start-profiling">
321+
<ConfigKey name="start-profiler-on-app-start">
319322

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.
323+
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.
324+
325+
- 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
326+
- 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
321327

322328
</ConfigKey>
323329

324-
## Continuous Profiling Options
330+
## Legacy Profiling Options
325331

326-
<Alert>
332+
<Alert title="✨ Note">
327333

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

330336
</Alert>
331337

332-
<ConfigKey name="profile-session-sample-rate">
338+
<ConfigKey name="profiles-sample-rate">
333339

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>.
340+
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.
335341

336342
</ConfigKey>
337343

338-
<ConfigKey name="profile-lifecycle">
339-
340-
Whether the profiling lifecycle is controlled manually or based on the trace lifecycle. Possible values are:
344+
<ConfigKey name="profiles-sampler">
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+
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.
344347

345348
</ConfigKey>
346349

347-
<ConfigKey name="start-profiler-on-app-start">
348-
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.
350+
<ConfigKey name="enable-app-start-profiling">
350351

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
352+
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.
353353

354354
</ConfigKey>

docs/platforms/android/index.mdx

Lines changed: 10 additions & 13 deletions
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,10 +80,10 @@ 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" />
9289
<!-- record session replays for 100% of errors and 10% of sessions -->
@@ -99,7 +96,7 @@ Configuration is done via the application `AndroidManifest.xml`. Here's an examp
9996

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

102-
```java
99+
```java {"onboardingOptions": {"profiling": "9-10", "profiling": "16-17"}}
103100
import androidx.appcompat.app.AppCompatActivity;
104101
import android.os.Bundle;
105102
import java.lang.Exception;
@@ -108,35 +105,35 @@ 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.
108+
// Any code running after this line will be profiled, if lifecycle is set to `manual`.
113109
Sentry.startProfiler();
114110
try {
115111
throw new Exception("This is a test.");
116112
} catch (Exception e) {
117113
Sentry.captureException(e);
118114
}
115+
// 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.
119116
Sentry.stopProfiler();
120117
}
121118
}
122119
```
123120

124-
```kotlin
121+
```kotlin {"onboardingOptions": {"profiling": "8-9", "profiling": "15-16"}}
125122
import androidx.appcompat.app.AppCompatActivity
126123
import android.os.Bundle
127124
import io.sentry.Sentry
128125

129126
class MyActivity : AppCompatActivity() {
130127
override fun onCreate(savedInstanceState: Bundle?) {
131128
super.onCreate(savedInstanceState)
132-
// Any code running after this line will be
133-
//profiled until Sentry.stopProfiler() is called.
129+
// Any code running after this line will be profiled, if lifecycle is set to `manual`.
134130
Sentry.startProfiler()
135131
try {
136132
throw Exception("This is a test.")
137133
} catch (e: Exception) {
138134
Sentry.captureException(e)
139135
}
136+
// 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.
140137
Sentry.stopProfiler()
141138
}
142139
}

0 commit comments

Comments
 (0)