Flutter performance traces
The SDK lets you measure how long the operations that matter in your Flutter app take on real devices, such as checkout, registration or image processing. You start a trace in Dart, stop it when the work is done, and enabling the feature also records an App Start trace for every launch, until Flutter shows its first frame.
Each trace records its duration and can include a small set of custom attributes to help you compare performance across different code paths. Mobile performance traces and app start monitoring shows how the Dashboard follows the duration percentiles and target of each trace, and compares them by attribute, app version and device model.
Enable performance traces
AppeliumFeedback.start(
apiKeys: apiKeys,
performanceTraces: PerformanceTracesConfiguration.enabled,
);
This also enables the automatic App Start trace.
Measure an operation
Start a trace with a descriptive name, add attributes, and stop it when the operation finishes:
final trace = AppeliumFeedback.startPerformanceTrace(name: 'checkout');
trace?.setValue('cart', forAttribute: 'flow');
trace?.setValue(user.tier.name, forAttribute: 'userTier');
// Perform the work you want to measure
trace?.stop();
- Trace names and attribute keys are constants, such as string literals or
constvariables, which the Dart analyzer checks. This keeps the number of distinct traces small and stops user data from leaking into names: each name is a trace of its own. Put values that change into attribute values instead. startPerformanceTracereturnsnullwhen performance traces are disabled, the SDK has not been started, or the name is blank.- On a simulator or an emulator, and while a native debugger is attached, you get a trace, but it is not recorded.
- Traces are uploaded when the app moves to the background, or on the next launch.
Attributes
Attach up to 5 attributes to each trace, for example the flow, the experiment variant or the user tier:
- Setting a key again overwrites its value without using another slot.
- After 5 distinct keys, further keys are ignored.
- Attributes set after
stop()are ignored.
Stop a trace
Calling stop() more than once has no effect, so it is safe to stop a trace on every exit path:
Future<List<Recommendation>> loadRecommendations() async {
final trace = AppeliumFeedback.startPerformanceTrace(name: 'loadRecommendations');
try {
return await api.recommendations();
} finally {
trace?.stop();
}
}
trace.isStopped tells you whether the trace has already been stopped.
Automatic traces
The SDK automatically records an App Start trace that measures the time from process creation until Flutter shows its first frame. It is recorded once per launch and requires no code, as long as you call start in main before runApp.
Only launches for the user are measured, as in native apps. The trace is not recorded when the system launches the app in the background, for example for a push notification, and not when the app moves to the background before its first frame. If you start the SDK after the first frame, for example after the user's consent, the launch is not measured.
Limits
| Value | Maximum |
|---|---|
| Trace name | 100 characters |
| Attribute key | 32 characters |
| Attribute value | 100 characters |
| Distinct attributes per trace | 5 |
Longer values are truncated.