This document describes the launch analysis API of the mobile monitoring iOS SDK, covering how to configure app launch data collection, configure a custom end time for cold starts, define custom cold start stages, and end a cold start.
1. Configure app launch collection
Enables or disables app launch data collection. This feature is enabled by default.
API definition
+ (void)setDataCollectionEnabled:(BOOL)dataCollectionEnabled;
+ (BOOL)dataCollectionEnabled;class var dataCollectionEnabled: Bool { get set }Code example
#import "AlicloudApmPerformance/AlicloudApmPerformance.h"
// Enable app launch data collection.
[EAPMLaunchConfiguration setDataCollectionEnabled:YES];
// Check the status of app launch data collection.
BOOL enabled = [EAPMLaunchConfiguration dataCollectionEnabled];#import "AlicloudApmCrashAnalysis/AlicloudApmCrashAnalysis.h"
// Enable app launch data collection.
LaunchConfiguration.dataCollectionEnabled = true
// Check the status of app launch data collection.
let enabled = LaunchConfiguration.dataCollectionEnabled2. Set custom cold start end time
Specifies whether your application manually sets the end time of a cold start.
API definition
+ (void)setCustomColdLaunchEndTime:(BOOL)customColdLaunchEndTime;
+ (BOOL)customColdLaunchEndTime;class var customColdLaunchEndTime: Bool { get set }Code example
#import "AlicloudApmPerformance/AlicloudApmPerformance.h"
// Enable a custom end time for cold starts.
[EAPMLaunchConfiguration setCustomColdLaunchEndTime:YES];
// Check if a custom cold start end time is enabled.
BOOL enabled = [EAPMLaunchConfiguration customColdLaunchEndTime];#import "AlicloudApmCrashAnalysis/AlicloudApmCrashAnalysis.h"
// Enable a custom end time for cold starts.
LaunchConfiguration.customColdLaunchEndTime = true
// Check if a custom cold start end time is enabled.
let enabled = LaunchConfiguration.customColdLaunchEndTime3. Start a cold start stage
Starts a custom stage for the current cold start trace. This action automatically ends the previous custom stage.
API definition
+ (void)startStageNamed:(NSString *)stageName;
+ (void)startStageNamed:(NSString *)stageName startTime:(NSDate *)startTime;class func startStage(name stageName: String)
class func startStage(name stageName: String, startTime: Date)Parameters
Parameter | Type | Required | Length Range | Description |
stageName | NSString | Yes | 1–128 | The name of the stage. |
startTime | NSDate | No | The start time of the stage. |
Code example
#import "AlicloudApmPerformance/AlicloudApmPerformance.h"
// Start a custom stage with a specified start time.
[EAPMLaunchMonitor startStageNamed:@"stage1" startTime:[NSDate date]];
// Start a new stage at the current time.
[EAPMLaunchMonitor startStageNamed:@"Stage2"];#import "AlicloudApmPerformance/AlicloudApmPerformance.h"
// Start a custom stage with a specified start time.
LaunchMonitor.startStage(name: "stage1", startTime: Date())
// Start a new stage at the current time.
LaunchMonitor.startStage(name: "stage2")4. Backfill a cold start stage
Adds a stage to the cold start trace with a specified start and end time.
API definition
+ (void)addStageNamed:(NSString *)stageName
startTime:(NSDate *)startTime
endTime:(NSDate *)endTime;class func addStage(name stageName: String, startTime: Date, endTime: Date)Parameters
Parameter | Type | Required | Length Range | Description |
stageName | NSString | Yes | 1–128 | The name of the stage. |
startTime | NSDate | Yes | The start time of the stage. | |
endTime | NSDate | Yes | The end time of the stage. |
Code example
#import "AlicloudApmPerformance/AlicloudApmPerformance.h"
NSDate *start = [NSDate dateWithTimeIntervalSinceNow:-0.2];
NSDate *end = [NSDate date];
[EAPMLaunchMonitor addStageNamed:@"read_cache" startTime:start endTime:end];#import "AlicloudApmPerformance/AlicloudApmPerformance.h"
let start = Date(timeIntervalSinceNow: -0.2)
let end = Date()
LaunchMonitor.addStage(name: "read_cache", startTime: start, endTime: end)5. End the cold start
Ends the cold start trace at the current time or at a specified time.
API definition
+ (void)endColdLaunch;
+ (void)endColdLaunchWithTime:(NSDate *)endTime;class func endColdLaunch()
class func endColdLaunch(endTime: Date)Parameters
Parameter | Type | Required | Description |
endTime | NSDate | Yes | The end time of the cold start. |
Code example
#import "AlicloudApmPerformance/AlicloudApmPerformance.h"
// End the cold start trace at the current time.
[EAPMLaunchMonitor endColdLaunch];
// End the cold start trace at a specified time.
[EAPMLaunchMonitor endColdLaunchWithTime:[NSDate date]];#import "AlicloudApmPerformance/AlicloudApmPerformance.h"
// End the cold start trace at the current time.
LaunchMonitor.endColdLaunch()
// End the cold start trace at a specified time.
LaunchMonitor.endColdLaunch(endTime: Date())