You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Check out the <PlatformLink to="/tracing/">tracing setup documentation</PlatformLink> for more detailed information on how to configure sampling. Setting the sample rate to 1.0 means all transactions will be captured.
50
+
By default, `sessionSampleRate` is `0`, so you'll need to set it to a higher value to receive profile data. `sessionSampleRate` is evaluated once per user session and applies to any attempt to start a profile until the next user session starts. See <PlatformLink to="/configuration/releases/#sessions">user session documentation</PlatformLink> for more information on user sessions.
42
51
43
-
By default, some transactions will be created automatically for common operations like loading a view controller/activity and app startup.
52
+
See the subsections below to learn about the various ways the profiler can be started and stopped.
44
53
45
-
## Enable Profiling
54
+
### Manual Lifecycle
55
+
56
+
By default, the profiler can only be started and stopped manually with calls to `SentrySDK.startProfiler` and `SentrySDK.stopProfiler`. All code that executes on all threads in between those calls will be recorded. The configurations shown above demonstrate configuring manual profiling mode.
57
+
58
+
### Trace Lifecycle
59
+
60
+
The profiler can be configured to start when a new root span is started where none already exist, and stopped when there are no root spans remaining. For this mode, you must set the `SentryProfileOptions.lifecycle` property to `SentryProfileLifecycleTrace` and ensure some traces will be sampled:
The `sessionSampleRate` for profiles is undersampled with respect to the `tracesSampleRate`.
91
+
92
+
</Alert>
93
+
94
+
Check out the <PlatformLink to="/tracing/">tracing setup documentation</PlatformLink> for more detailed information on how to configure sampling for Sentry Tracing.
95
+
96
+
### App Starts
97
+
98
+
If configured with manual lifecycle, then a profile starts on the next app launch, and continues until you call `SentrySDK.stopProfiler`.
99
+
100
+
If configured with trace lifecycle, then app start profiles are attached to a special performance transaction operation called `app.launch` and displayed in the product simply as `launch`, which is stopped either when `SentrySDK.startWithOptions` is called, or, if <PlatformLink to="/tracing/instrumentation/automatic-instrumentation/#time-to-initial-display">TTID</PlatformLink>/<PlatformLink to="/tracing/instrumentation/automatic-instrumentation/#time-to-full-display">TTFD</PlatformLink> tracking is enabled, when the SDK determines that TTID/TTFD has been reached.
101
+
102
+
Every time `SentrySDK.startWithOptions` is called with app start profiling configured, a separate sample decision is generated with `sessionSampleRate` and stored until the next app launch (as well as `tracesSampleRate` if trace profile lifecycle is configured). The same sample decision will apply for the remainder of the profile session following that subsequent launch.
103
+
104
+
## Transaction Profiling (deprecated)
46
105
47
106
<Alert>
48
107
49
-
iOS profiling is available starting in SDK version `8.12.0`.
108
+
Profiling configuration as explained below was originally introduced in SDK version `8.12.0` and is deprecated in favor of profiling V2 introduced in 8.49.0, explained at the beginning of this section.
50
109
51
110
</Alert>
52
111
112
+
<Alert>
113
+
114
+
Profiling depends on Sentry’s Tracing product being enabled beforehand. Check out the <PlatformLink to="/tracing/">tracing setup documentation</PlatformLink> for more detailed information on how to configure sampling.
115
+
116
+
</Alert>
117
+
118
+
Configure the sampling rates for traces and profiles to ensure they are nonzero so that some are recorded. The <PlatformIdentifier name="profiles-sample-rate" /> setting is _relative_ to the <PlatformIdentifier name="traces-sample-rate" /> setting.
53
119
54
120
```swift {tabTitle:Swift}
55
121
import Sentry
@@ -58,7 +124,6 @@ SentrySDK.start { options in
58
124
options.dsn = "___PUBLIC_DSN___"
59
125
options.tracesSampleRate = 1.0 // tracing must be enabled for profiling
60
126
options.profilesSampleRate = 1.0 // see also `profilesSampler` if you need custom sampling logic
61
-
options.enableAppLaunchProfiling = true // experimental new feature to start profiling in the pre-main launch phase
62
127
}
63
128
```
64
129
@@ -69,26 +134,17 @@ SentrySDK.start { options in
69
134
options.dsn= @"___PUBLIC_DSN___";
70
135
options.tracesSampleRate= @1.0; // tracing must be enabled for profiling
71
136
options.profilesSampleRate= @1.0; // see also `profilesSampler` if you need custom sampling logic
72
-
options.enableAppLaunchProfiling=YES; // experimental new feature to start profiling in the pre-main launch phase
73
137
}];
74
138
```
75
139
76
-
<Alert>
77
-
78
-
The <PlatformIdentifier name="profiles-sample-rate" /> setting is _relative_ to the <PlatformIdentifier name="traces-sample-rate" /> setting.
79
-
80
-
</Alert>
81
-
82
-
## Enable Launch Profiling
140
+
## Launch Profiling (deprecated)
83
141
84
142
<Alert>
85
143
86
-
This feature is experimental and may have bugs.
144
+
Launch profiling configuration as explained below was originally introduced in SDK version 8.21.0 and is deprecated in favor of profiling V2 configuration released in 8.49.0, explained at the beginning of this section.
87
145
88
146
</Alert>
89
147
90
-
_(New in version 8.21.0)_
91
-
92
148
Normally, a profile can only be taken during a trace span after the SDK has been initialized. Now, you can configure the SDK to automatically profile certain app launches.
93
149
94
150
To set up launch profiling, use the `enableAppLaunchProfiling` option and configure the sample rates for traces and profiles with `SentrySDK.startWithOptions` to determine if the subsequent app launch should be automatically profiled. This allows you to gather information on what is going on in your app even before `main` is called, making it easier to diagnose issues with slow app launches.
@@ -97,16 +153,36 @@ If you use `SentryOptions.tracesSampler` or `SentryOptions.profilesSampler`, it
97
153
98
154
Currently, launch profiles are attached to a special performance transaction operation called `app.launch` and displayed in the product simply as `launch`.
99
155
100
-
## Continuous Profiling
156
+
```swift {tabTitle:Swift}
157
+
import Sentry
158
+
159
+
SentrySDK.start { options in
160
+
options.dsn = "___PUBLIC_DSN___"
161
+
options.tracesSampleRate = 1.0 // tracing must be enabled for profiling
162
+
options.profilesSampleRate = 1.0 // see also `profilesSampler` if you need custom sampling logic
options.tracesSampleRate= @1.0; // tracing must be enabled for profiling
173
+
options.profilesSampleRate= @1.0; // see also `profilesSampler` if you need custom sampling logic
174
+
options.enableAppLaunchProfiling=YES;
175
+
}];
176
+
```
177
+
178
+
## Continuous Profiling (deprecated)
101
179
102
180
<Alert>
103
181
104
-
This feature is experimental and may have bugs.
182
+
Continuous profiling as explained below was originally introduced in SDK version 8.36.0 and is deprecated in favor of profiling V2 configuration released in 8.49.0, explained at the beginning of this section.
105
183
106
184
</Alert>
107
185
108
-
_(New in version 8.36.0)_
109
-
110
186
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.
111
187
112
188
Previously, profiles only ran in tandem with performance transactions that were started either automatically or manually with `SentrySDK.startTransaction`. Now, you can start and stop the profiler directly with `SentrySDK.startProfiler` and `SentrySDK.stopProfiler`. You can also start a profile at app launch by setting `SentryOptions.enableAppLaunchProfiling = true` in your call to `SentrySDK.startWithOptions`.
0 commit comments