iOS アプリケーションのインストゥルメント化

EUM アプリケーションキーを取得し、iOS アプリケーションをインストゥルメント化するには、次の手順を実行します。

アプリケーションキーの取得

Getting Started Wizard を完了すると、EUM アプリケーションキーが付与されます。このキーは、ソースコードを変更するときに必要になります。場合によっては、複数のモバイルアプリケーションが同じキーを共有できます。

[Getting Started Wizard] を完了したものの、EUM アプリケーションキーを持っていない場合は、「アプリケーションキーの取得」を参照してください。

Initialize the Agent

Objective-C

Edit your app's AppDelegate.m file to initialize the Mobile Agent as soon as the app launches. This registers your application and only needs to be done once in your code.

  1. In the AppDelegate.m file, add this import statement:
    #import <ADEumInstrumentation/ADEumInstrumentation.h>
  2. In the method didFinishLaunchingWithOptions, create an ADEumAgentConfiguration object with the EUM App Key that you received when completing the Getting Started Wizard to initialize the iOS Agent:o initialize the iOS Agent:
    // Example EUM App Key: "AAA-AAB-AUM"
    ADEumAgentConfiguration *config = [[ADEumAgentConfiguration alloc] initWithAppKey:<#EUM_APP_KEY#>];
    Your code should look something like the following:
    #import <ADEumInstrumentation/ADEumInstrumentation.h>
    #import "AppDelegate.h"
     
        // ...
        -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
        {
            // Example EUM App Key: "AAA-AAB-AUM"
            ADEumAgentConfiguration *config = [[ADEumAgentConfiguration alloc] initWithAppKey:<#EUM_APP_KEY#>]; 
            // other tasks
            return YES;
        }
    
  3. Configure the iOS Agent to report metrics and screenshots to the SaaS EUM Server in your region and initialize the agent by passing the ADEumAgentConfiguration object to the method initWithConfiguration. If you are using an on-premises EUM Server, see Configure the iOS Agent for On-Prem Deployments (Optional).
    #import <ADEumInstrumentation/ADEumInstrumentation.h>
    #import "AppDelegate.h"
     
        // ...
        -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
        {
            ADEumAgentConfiguration *config = [[ADEumAgentConfiguration alloc] initWithAppKey:<#EUM_APP_KEY#>];
            //The default SaaS EUM Server and Screenshot Service are in the Americas, 
    		// so you can omit the following settings if you are in the Americas.
            config.collectorURL = @"https://<your_region>-col.eum-appdynamics.com";
            config.screenshotURL = @"https://<you_region>-image.eum-appdynamics.com/";
            [ADEumInstrumentation initWithConfiguration: config];
            // other tasks
            return YES;
         }
    
  4. (Optional) If your application is using another tool to report crashes, the iOS Agent may warn you with the following message:
    Agent has detected a third party crash reporting tool. You may wish to disable AppDynamics Crash Reporting by setting the crashReportingEnabled configuration flag to NO
    You are recommended to use only one crash reporting tool for better results. See Disable Crash Reporting for instructions on how to disable the iOS Agent's crash reporting.
  5. Save the file.
Swift

The iOS Agent is compatible with applications created using the Swift programming language.

  1. In your application's AppDelegate class, add this import statement:
    import ADEumInstrumentation
  2. In the AppDelegate class didFinishLaunchingWithOptions, create an ADEumAgentConfiguration object with the EUM App Key that you received when completing the Getting Started Wizard to initialize the iOS Agent:
    #import <ADEumInstrumentation/ADEumInstrumentation.h>
    #import "AppDelegate.h"
     
        // ...
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
            let config = ADEumAgentConfiguration(appKey: <#EUM_APP_KEY#>)
        }
  3. Configure the iOS Agent to report metrics and screenshots to the SaaS EUM Server in your region, and initialize the agent by passing the initWith() method that takes the ADEumAgentConfiguration object as a parameter.
    注: If you are using an on-premises EUM Server, see Configure the iOS Agent for On-Prem Deployments (Optional).
    #import <ADEumInstrumentation/ADEumInstrumentation.h>
    #import "AppDelegate.h"
     
        // ...
         func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
            let config = ADEumAgentConfiguration(appKey: <#EUM_APP_KEY#>)
            config.collectorURL = "https://<your_region>.eum-appdynamics.com"
            config.screenshotURL = "https://<your_region>-image.eum-appdynamics.com"
            ADEumInstrumentation.initWith(config)
            // other tasks
            return true
        }
    // ...
  4. (Optional) If your application is using another tool to report crashes, the iOS Agent will warn you with the following message:
    Agent has detected a third party crash reporting tool. You may wish to disable AppDynamics Crash Reporting by setting the crashReportingEnabled configuration flag to NO
    We recommend you use only one crash reporting tool for better results. See Disable Crash Reporting for instructions on how to disable the iOS Agent's crash reporting.
  5. Save the file.
Apple Watch Extensions

Apps written for watchOS 1 contain a WatchKit extension that runs on the user's iPhone, but watchOS 2 also supports a new architecture, where the WatchKit extension runs on the Apple Watch itself. Splunk AppDynamics supports the watchOS 1 architecture, but not the new watchOS 2 architecture. Note that apps using the watchOS 1 architecture can run on both watchOS 1 and 2, so if your application is designed for watchOS 1, you can use Splunk AppDynamics on both versions of watchOS.

Because watchOS 1 apps are functionally launched in response to an interaction with the Watch UI, the SDK initialization code should be called at the point of that interaction in the iPhone app, which is usually not at the extension's AppDelegate.m call. The syntax remains the same.

dSYM ファイルの生成

アプリケーションがクラッシュした場合に生成されるクラッシュスナップショットに、人間が判読可能な情報をエージェントが提供できるようにするには、[ ] ファイルオプションを使用してコンパイルし、アプリケーションのデバッグシンボル(dSYM)ファイルを生成します。これを行う理由について詳しくは、「人間が判読可能なクラッシュスナップショットの取得」を参照してください。

  1. Xcode の Project Navigator でプロジェクトを選択します。
  2. ターゲットリストで、アプリケーションを構築するターゲットを選択します。
  3. [Build Settings] タブを選択します。
  4. [Build Options] セクションで、Debug Information FormatDWARF with dSYM File に設定されていることを確認します。
  5. Xcode プロジェクトを再構築します。

dSYM ファイルによるクラッシュのモニタ

この手順はオプションですが、クラッシュをモニターする場合は強く推奨します。Splunk AppDynamics は、アプリケーションがクラッシュスナップショット用に判読可能なスタックトレースを生成するために、dSYM ファイルを必要とします。

手順は、「dSYM ファイルのアップロード」を参照してください。

インストゥルメンテーションのカスタマイズ(オプション)

ADEumInstrumentation クラスには、Splunk AppDynamics を使用して収集および集約できるデータの種類を拡張できる追加のメソッドがあります。作成できる拡張には、次の 5 つの基本タイプがあります。

  • カスタムタイマー:コード内の任意のイベントシーケンスが、複数のメソッドにまたがる場合でも、時間を計測できます
  • カスタムメトリック:収集する任意の整数ベースのデータ
  • ユーザデータ:任意の文字列キーと値のペアが役立つ可能性があります
  • インフォメーションポイント:1 つのメソッドが呼び出される頻度と実行にかかる時間
  • トピックパス(パンくずリスト):クラッシュのコンテキスト

iOS インストゥルメンテーションのカスタマイズ」を参照してください。

Configure the iOS Agent for On-Premises Deployments (Optional)

By default, the agent is configured to send its beacons to the EUM Cloud, which is an instance of the EUM Server running on AWS. If you wish to instrument your app in an environment that is using an on-premises version of the EUM Server, you need to modify the URL to which the agent sends its beacons. You do this using the ADEumAgentConfiguration object to set the Collector URL and the Screenshot Service URL to your on-premises EUM Server URL.

注: The iOS Agent knows which path to use to make calls to different services (Collector/Screenshot Service). For example, if the EUM Server URL is https://myEUMServerURL.com:7001, the iOS Agent will know to use https://myEUMServerURL.com:7001/eumcollector to make requests to the EUM Collector. By specifying the Collector URL, you will not be able to use the SaaS deployment of the EUM Cloud for the Screenshot Service.

To get the EUM Server URL:

  1. Open the Administration Console.
  2. From the left navigation bar, click Controller Settings.
  3. In the search field, enter eum.beacon.host or eum.beacon.https.host if you're using HTTPS.
  4. Copy the value for the configuration. This is your EUM Server URL.
The code examples below show how to set the Collector URL and Screenshot Service URL using Objective-C and Swift.
Objective-C
ADEumAgentConfiguration *adeumAgentConfig = [[ADEumAgentConfiguration alloc] initWithAppKey:<#EUM_APP_KEY#>];
// Set the Collector URL and Screenshot Service URL to the EUM Server URL.
adeumAgentConfig.collectorURL = <#COLLECTOR_URL:PORT#>;
adeumAgentConfig.screenshotURL = adeumAgentConfig.collectorURL;
[ADEumInstrumentation initWithConfiguration:adeumAgentConfig];
Swift
let configuration = ADEumAgentConfiguration(appKey: <#EUM_APP_KEY#>)
// Set the Collector URL and Screenshot Service URL to the EUM Server URL.
config.collectorURL = <#COLLECTOR_URL:PORT#>
config.screenshotURL = config.collectorURL
ADEumInstrumentation.initWith(configuration)

Enable HTTP to Send Beacons to On-Premises EUM Servers

If you use an on-premises EUM Server and you wish to use HTTP to dispatch your beacons to the EUM Server, starting with iOS 9 you need to set a flag in your app's info.plist file to allow it to use the unsecured connection. By default, HTTPS is enforced in all iOS 9 applications by App Transport Security (ATS), and the iOS Agent complies with ATS when used with the EUM Cloud.