Docs » Get your iOS data in

Get your iOS data in 🔗

Follow these steps to instrument your iOS application and get data into Splunk RUM for Mobile.

Prerequisites and requirements 🔗

The following table describes the prerequisites and requirements:

  • You need to know your Splunk RUM access token. For more, see Generate your RUM access token in the Observability Cloud.

  • Access the source code of your application. For example, the Xcode project.

  • Your beaconUrl is provided to you by your Splunk representative.

  • Splunk RUM for Mobile supports iOS 11 and up (and iPadOS 13 and up).

  • You need to know your Splunk realm. To learn more about realms, see Note about realms.

Installation configuration options 🔗

The following table describes the installation configuration options:

Configuration option

Type

Description

Default

beaconUrl

String (required)

The full URL of the RUM ingest endpoint

n/a

rumAuth

String (required)

The rumAuth is the RUM Token you generate in the Observability Cloud. RUM access tokens are publicly visible in the client-side code

n/a

debug

Bool

Turns the debug logging on or off

false

allowInsecureBeacon

Bool

Allows http beacon urls

false

globalAttributes

[String:Any]

Extra attributes to add to each reported span. See also setGlobalAttributes

[:]

Import and initialize the Splunk RUM iOS library 🔗

Follow these steps to import and initialize the Splunk RUM iOS library.

  1. In Xcode, select File > Swift Packages > Add Package Dependency. To find the latest release, go to Releases on GitHub for splunk-otel-ios.

.package(url: "https://github.com/signalfx/splunk-otel-ios/", from: "<latest release>");
...
.target(name: "MyApp", dependencies: ["SplunkRum"]),
  1. Initialize the Splunk RUM iOS library with your configuration parameters. There are two options, you can either use swift or objective C. Your rumAuth is the RUM token you generated. For more information, see Generate your RUM access token in the Observability Cloud.

import SplunkRum
..
SplunkRum.initialize(beaconUrl:"https://rum-ingest.<your Observability realm>.signalfx.com/v1/rum", rumAuth: "<your RUM access token>")
  1. Deploy the changes to your application.

(Optional) Include crash reporting 🔗

Splunk OpenTelemetry iOS agent Crash Reporting module is an add-on to the Splunk RUM iOS agent. Symbolication is not supported. For more information on the crash reporting for the Splunk RUM iOS agent, see README in splunk-otel-ios-crashreporting on GitHub.

Follow these steps:

  1. In Xcode, select File > Swift Packages > Add Package Dependency. To find the latest release, go to Releases on GitHub for splunk-otel-ios.

.package(url: "https://github.com/signalfx/splunk-otel-ios/", from: "<latest release>");
.package(url: "https://github.com/signalfx/splunk-otel-ios-crashreporting/", from: "<latest release>");
...
.target(name: "MyApp", dependencies: ["SplunkOtel", "SplunkOtelCrashReporting]),
  1. Initialize the crash reporting module with your configuration parameters. There are two options, you can either use Swift or Objective C.

import SplunkOtel
import SplunkOtelCrashReporting
...
SplunkRum.initialize(beaconUrl: "https://rum-ingest.<your Observability realm>.signalfx.com/v1/rum", rumAuth: "<your RUM access token>")
SplunkRumCrashReporting.start()

(Optional) Manually instrument for iOS application 🔗

You can modify the OpenTelemetry instrumentation to customize names, add global attributes, and more.

Configure error reporting 🔗

You can report handled errors, exceptions, and messages with a convenience API.

Example

In this example, example_error represents an error. There are reportError overloads for string, error, and NSException.

SplunkRum.reportError(example_error)

Manage global attributes 🔗

Global attributes are key-value pairs added to all reported data. Global attributes are useful for reporting app or user-specific values as tags.

Example

Suppose you want to filter spans by account type. In our organization, there are three types of account plans: gold, silver, and bronze.

You add accountType={gold,silver,bronze} to every span reported by the Splunk RUM iOS library. Then, you can specify global attributes during SplunkRum.initialize() as options.globalAttributes or use SplunkRum.setGlobalAttributes or SplunkRum.removeGlobalAttribute at any point during your app’s execution.

Manually change screen names 🔗

By default, the Splunk RUM iOS library captures the name of ViewController. You can customize the screen names for your application. The name you choose persists until your next call to setScreenName.

Example

Suppose you want to customize the name of your account settings screen in your application:

SplunkRum.setScreenName("AccountSettingsTab")

After you set the setScreenName parameter, it disables automatic screen name instrumentation, to avoid overwriting your chosen name(s). If you instrument your application to setScreenName, apply it to all screen names.

Tracing API 🔗

You can use the OpenTelemetry Swift APIs to report on events in your mobile application.

Example

Suppose you have this calculateTax function you wanted to time:

func calculateTax() {
let tracer = OpenTelemetrySDK.instance.tracerProvider.get(instrumentationName: "MyApp")
let span = tracer.spanBuilder(spanName: "calculateTax").startSpan()
span.setAttribute(key: "numClaims", value: claims.count)
...
...
span.end() // or use defer for this
}

Span Filtering 🔗

You can modify or reject spans with a spanFilter function. This is supported only in Swift. This example show how to remove a span.

Example

options.spanFilter = { spanData in
  var spanData = spanData
  if spanData.name == "DropThis" {
    return nil // spans with this name will not be sent
  }
  var atts = spanData.attributes
  atts["http.url"] = .string("redacted") // change values for all urls
  return spanData.settingAttributes(atts)
}

Advanced usage 🔗

For more, see the README in the splunk-otel-ios project on GitHub.