Help APM Mobile APM for iOS

iOS APM

Site24x7 Mobile APM for iOS lets you track the performance of your native mobile applications on actual end-user devices. For example, a news reader application may perform the following operations internally:

  • Navigate to a table view to show a list of articles
  • Load the list of articles using a REST API call
  • Cache the list of articles in an SQLite database
  • Download a thumbnail for each article
  • Cache the thumbnails to the filesystem
  • Build a complex UI such as a custom table view cell style

All of the above are potentially long-running operations that impact user experience so it's important to benchmark and optimize them across various devices. Site24x7 Mobile APM gathers and aggregates metrics from all your users across the globe by embedding an APM agent in your applications in the form of a library.

The APM agent measures the execution time of your code using transactions and components. In the previous example, the entire sequence of operations from starting navigation to rendering the final UI can be considered a transaction. The individual operations can be grouped into different component types such as HTTP, SQLite, filesystem, UI etc. Simple operations can be measured using just transactions, while complex operations can be measured using transactions with components.

Learn about:

Add Mobile APM? 

  1. Login to Site24x7 and go to iOS section under APM tab.
  2. Click on Add Application button.
  3. Enter the Application Name and Apdex Threshold and click Save.
  4. On successful addition, you will be provided with an application key and a link to download the library files (Mobile_APM_iOS.zip). The same application key must be used for all versions of your application.
  5. You can copy the application key by clikcing on the hanburger icon near your app name in the application screen.

Install Mobile APM via cocopods (for Swift)

  1. Step 1:

    Add Mobile APM iOS SDK to your podfile.

    source'https://github.com/site24x7/MobileAPM-IOS-SDK.git'
    target 'Your_Project_Name' do
    use_frameworks!
    pod 'Site24x7APM', '0.0.1'
    end
  2. Step 2:

    Run the below command in your terminal

    pod install
  3. Step 3:

    Set Debug Information format as DWARF with dysm File in Build Settings.

  4. Step 4:

    Add new run script build phase .

    Note : Ensure Z_APP_CONFIG key is generated in info.plist and the right API_KEY is configured correctly after building your application.

    ls -l
    eval "./{Path to run script and dsym_upload file}/run" --api-key= --upload-symbols=true
  5. Step 5:

    Initialise your SDK and build your project .

    import UIKit
    import APMClick to copy 
    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    S24APM.startMonitoring();
    return true;
    }
    }

Install Mobile APM manually

Instead of istalling via cocoapods, we can also manually add the framework file directly to the project .

  1. Download the Mobile APM iOS SDK to instrument and rebuild your native app. Drag from Downloads to the root of your project and make sure 'Copy items if needed' is checked when prompted for options in Xcode.
  2. Unzip and add APM_{version}.framework and ZAnalytics_{version}.framework to the root of the project directory and make sure 'Copy items if needed' is checked when prompted for options in Xcode. Note : Make sure you add the frameworks as an Embedded Binaries

The remaining steps are the same as the one specified in installation via cocoapods.(step 3 - step 6).

Start a transaction

You should typically start a transaction before a long-running operation and stop it when the operation is complete. Transactions are thread-safe and can be started and stopped from different threads. A transaction object can only be started and stopped once. Transactions with the same name are averaged across the application. Thus, when the same operation is executed multiple times using the same transaction name, the average execution time is recorded.

- (void)listArticles {
    S24Transaction *transaction = [S24APM startTransactionWithName:@"List Articles"];/
    // Perform long-running operation./
    [S24APM stopTransaction:transaction];
}

Group operations within a transaction using components?

You can group operations within a transaction into different types of components. You can use one of the predefined types such as S24HttpComponent.TYPE_HTTP, Component.TYPE_SQLITE, Component.TYPE_UI etc., or specify your own type. Components are thread-safe and can be started and stopped from different threads. A component object can only be started and stopped once. A component object cannot be stopped after its parent transaction has already been stopped. Multiple components in a transaction can overlap and run in parallel. Components with the same name within a transaction are averaged.

- (void)listArticles {
    S24Transaction *transaction = [S24APM startTransactionWithName:@"List Articles"];
    S24Component *httpComponent = [transaction startComponentWithType:S24HttpComponent];
    S24Component *articlesComponent = [transaction startComponentWithType:@"Download Articles"];
    // Download articles.
    [transaction stopComponent:articlesComponent];
    for (Article *article in articles) {
          S24Component *thumbnailComponent = [transaction startComponentWithType:@"Download Thumbnail"];
         // Download thumbnail.
         [transaction stopComponent:thumbnailComponent];
    }
       [transaction stopComponent:httpComponent];
       [S24APM stopTransaction:transaction];
}

In the above example, the total time taken by HTTP operations (downloading articles and thumbnails) are measured by S24HttpComponent and the time taken for just the articles is measured by "Download Articles". The time taken for each thumbnail is averaged and recorded by "Download Thumbnail" since it executes multiple times within a loop.

Flush the data?

Sometimes it's desirable to manually flush recently recorded data to Site24x7's servers. You may want to do this if you record transactions just before your application is terminated. If you've set a large upload interval (the default is 60 seconds), you should manually flush data whenever appropriate in case the application is terminated before the next upload interval.

[S24APM flush]

View the data

To view the data: 
  • Log in to your Site24x7 account > APM > iOS and click on your application.  
  • The dashboard lists all your mobile apps along with their statuses: Up, Down, Critical, or Trouble.  
  • Applications that have been suspended or have configuration errors are also listed here.  
  • For active applications, the following metrics are listed in the dashboard:  
    • Response time and throughput for the chosen time period compared with the previous time period 
    • Crashes for the chosen time period 
    • Apdex score and user count for the chosen time period

Metrics and Inference

The following metrics about your app can be viewed when you instrument the APM Insight API in your mobile applications: 
  1. Worldwide summary 
  2. Response time and throughput
  3. Response time by geographies, carriers, devices, and OSs
  4. Total response time, throughput, and response time split up of individual transactions 
  5. Crash analytics

1.Worldwide summary report

The worldwide summary report shows the performance of your application across all geographies for the chosen time period. The color code is based on the Apdex score, ranging from 0 to 1, with 0 denoting a frustrating user experience and 1 denoting a satisfied user experience.  You can hover over an individual region on the map to view the Apdex score, average response time, throughput, and errors for that particular location.

 2.Response time and throughput of the app

The total response time and throughput of the app for the chosen time period can be viewed from the Admin tab.

 3.Response time split up by geography, carrier, device, and OS version

Your application response time may be impacted by various reasons other than your application code. 

Comparing your app response time across geographies, devices, and OS versions will help you narrow down the issue. 

Response time by geographies and carriers can be viewed under the Geography tab.

Response time across various devices and OS versions can be seen under the Device Type tab. 

4.Response time of transactions

Response time, throughput, and count (the number of times that transaction was called) of individual transactions can be viewed under the Transactions tab.

5.Crash Analytics

You can view the number of crashes for the chosen time period by clicking on the Crash Analytics tab. You can hover over the stacked graph on the top, to view the number of crashes across various devices, the number of issues, and the number of users who were affected by this crash.  The middle band shows you the percentage change in the crashes — an increase or decrease in the total number of crashes along with the count of crash-free users. 

The crash summary lists the exceptions. You can click on the exception to find the exact line of error.

Configure Alerts

Get notified when your application response time exceeds the specified threshold level, by configuring alerts.

You can set alerts as Trouble or Critical based on the severity level. 

Follow the steps below to configure alerts:

  1. Log in to your Site24x7 account > APM > iOS. 
  2. Select your application > Hover over the hamburger icon > Edit monitor details.
  3. Under Configuration Profiles, click on (+) to add a new threshold and availability profile.
  4. Select your mobile application in Monitor Type and give a name for your alert.
  5. Enter the average response time value - you will receive alerts when your application response time exceeds this value.
  6. Click Save

You can tweak the settings in Notification profile, to decide when to receive alerts when your application goes DOWN. Additionally, you can also configure user alerts groups - this lets you decide who should receive alerts when triggered.   

Was this document helpful?
Thanks for taking the time to share your feedback. We’ll use your feedback to improve our online help resources.

Help APM Mobile APM for iOS