Performance Monitoring
Dependencies
Use cases
- To enable/ disable all kind of tracking, switch
enableAutoPerformanceTracing
- Record cold startup time and warm startup time
- Observe Navigation
- Capture User Interactions
- Capture Assets Performance
- Observe transactions
- Record Slow and Frozen frames (Yet to implement)
Auto Performance Tracking
- When
enableAutoPerformanceTracing
flag is set tofalse
nothing will be monitored.
Startup time
- To record cold startup time and warm startup time. Set
autoAppStart
totrue
. - Provides insight into how long your application takes to launch.
- Startup time is attached to first transaction that happens in app, so if app has no transaction nothing will be recorded. Learn about transactions here.
Capture User Interactions
- To capture User Interactions set
enableUserInteractionTracing
totrue
. - The UI instrumentation, once enabled, captures transactions and adds breadcrumbs for a set of different user interactions, which include clicks, long clicks, taps, and so on. The SDK composes the transaction name from the key of the Widget that captured the user interaction (for example, login_button). The transaction operation is set to ui.action.click.
- If the view doesn't have the key assigned, the transaction and the breadcrumb won't be captured because it can't be uniquely identified otherwise.
- The key value should be unique across the whole application because the transactions are grouped by its name.
Capture Assets Performance
- To capture Assets Performance set
enableAssetsInstrumentation
totrue
. - provides insight into how long your app takes to load its assets, such as files.
Observe Transactions
- Learn more about transactions here.
Record Slow and Frozen frames (Yet to implement)
Configuration
- To configure sentry for your project you just have to pass sentryConfig in environment config.
- Check this video for, how to get config values.
- To disable all kind of tracing set
enableAutoPerformanceTracing
tofalse
. - To record cold startup time and warm startup time set
autoAppStart
totrue
, check this section. - To record User Interaction set
enableUserInteractionTracing
totrue
, check this section. - To enable assets instrumentation set
enableAssetsInstrumentation
totrue
.
How to use?
Just toogle environment flags to enable/ disable monitoring.
Where is the code that handles this?
base_controller handles everything. So if developer is building on our app or has similar code of base_controller
in their core_controller or main
then they are good to go.
final EnvironmentConfig config = EnvironmentConfig.getEnvConfig();
if (null != config.sentryConfig && config.sentryConfig!.dsn.isNotEmpty) {
await SentryFlutter.init(
(options) => options
..dsn = config.sentryConfig!.dsn
..autoAppStart = config.sentryConfig!.autoAppStart
..tracesSampleRate = config.sentryConfig!.tracesSampleRate
..enableAutoPerformanceTracing = config.sentryConfig!.enableAutoPerformanceTracing
..enableUserInteractionTracing = config.sentryConfig!.enableUserInteractionTracing
..environment = config.envType,
);
Widget child = app; // Main (Material) App
if (config.sentryConfig!.enableUserInteractionTracing) {
child = SentryUserInteractionWidget(
child: child,
);
}
if (config.sentryConfig!.enableAssetsInstrumentation) {
child = DefaultAssetBundle(
bundle: SentryAssetBundle(
enableStructuredDataTracing: true,
),
child: child,
);
}
runApp(child);
} else {
runApp(app);
}
As you can see depending on environment variables we apply different performance monitoring mechanisms.
So to set those environment variables you need to pass something like shown below
sentryConfig: const SentryConfig(
dsn: '',
enableAutoPerformanceTracing: true,
autoAppStart: true,
enableUserInteractionTracing: true,
enableAssetsInstrumentation: true,
tracesSampleRate: 0.6,
),
Learn more about those environment variables here.