Splunk MINT SDK for iOS

Splunk MINT SDK for iOS Developer Guide

Download manual as PDF

Download topic as PDF

Trace Objective-C methods

If you are using Objective-C, you can log trace information on specific methods in your code to measure performance using the following macros:

MINT_METHOD_TRACE_START: Starts the method trace.
MINT_METHOD_TRACE_STOP: Stops the method trace.
MINT_NONARC_METHOD_TRACE_STOP: Stops the method trace. Use this macro if you are not using ARC.

Note  You cannot use this feature with Swift, which does not support macros.

To trace an Objective-C method, add a MINT_METHOD_TRACE_START call to the beginning of your method and a MINT_METHOD_TRACE_STOP call to the end of it, as follows:

// Objective-C
- (void)test {
    MINT_METHOD_TRACE_START
    
    NSLog(@"Hello, World");
    
    MINT_METHOD_TRACE_STOP
}

If you are not using ARC, use the MINT_NONARC_METHOD_TRACE_STOP macro to avoid a memory leak issue.

Then, run a search in Splunk Web on the "mint:methodinvocation" sourcetype to view trace information and performance metrics, for example:

index=mint sourcetype="mint:methodinvocation" | head 5

The trace method automatically picks up performance metrics for your method and sends it to Splunk Enterprise. The following fields contain trace information:

  • threadID: The thread ID.
  • method: The method that was traced.
  • elapsedTime: The elapsed time between starting and stopping the method trace, in nanoseconds.


Here's an example result:

 {
   apiKey: 12345
   appEnvironment: Testing
   appRunningState: Foreground
   appVersionCode: 1
   appVersionName: 1.0
   batteryLevel: -100
   carrier: NA
   connection: WIFI
   currentView: GHUnitIOSViewController
   device: x86_64
   elapsedTime: 52077306
   extraData: {
   }
   locale: US
   method: -[SplunkiOSTests testMethodTrace]
   msFromStart: 1679
   osVersion: 9.2
   packageName: SplunkTests
   platform: iOS
   remoteIP: 204.107.141.240
   screenOrientation: Portrait
   sdkVersion: 5.0.0
   session_id: 83B0BFA2-D224-4EE8-B65F-1A9C6A2A790A
   state: CONNECTED
   threadID: 19207
   transactions: {
   }
   userIdentifier: NA
   uuid: fake_uid
} 
PREVIOUS
View memory warnings
  NEXT
Disable network monitoring for URLs

This documentation applies to the following versions of Splunk MINT SDK for iOS: 5.2.x


Was this documentation topic helpful?

Enter your email address, and someone from the documentation team will respond to you:

Please provide your comments here. Ask a question or make a suggestion.

You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters