Configure the Splunk RUM Android agent

Configure the Splunk Observability Cloud real user monitoring (RUM) instrumentation for your Android applications.

AgentConfiguration

You can configure the Splunk RUM agent to add custom attributes, adapt the instrumentation to your environment and application, customize sampling, and more.

To configure the Splunk RUM Android agent, pass the settings to the agent in an AgentConfiguration object. The following example shows how to configure this object with your Splunk RUM token, Splunk realm, application name, and deployment environment:

Kotlin
KOTLIN
val agent = SplunkRum.install(
    application = this,
    agentConfiguration = AgentConfiguration(
        endpoint = EndpointConfiguration(
            realm = "your-splunk-realm",
            rumAccessToken = "your-splunk-rum-access-token"
        ),
        appName = "your-application-name",
        deploymentEnvironment = "your-environment-name"
    )
)
Java
CODE
SplunkRum agent = SplunkRum.install(
    this,
    new AgentConfiguration(
        new EndpointConfiguration(
            "your-splunk-realm",
            "your-splunk-access-token"
        ),
        "your-application-name",
        "your-environment-name"
    )
);

General settings

Use the following settings to configure the Splunk RUM Android agent's AgentConfiguration object:

Option Description
appName (required) Sets the application name.
appVersion Sets the application version.
deferredUntilForeground Defer telemetry until the app is brought to the foreground. Default: false
deploymentEnvironment(required) Environment for all the spans produced by the application. For example, dev, test, or prod.
enableDebugLogging Activates debug logging. Default: false
endpoint Sets the configuration needed to export data to an endpoint. There are two required inputs:

Starting from Splunk RUM Android agent version 2.1.0, you don't have to configure endpoints at installation time; you can configure them later using SplunkRum.instance.preferences. See examples.

forceEnableOnLowerApi

Enables run-time support for Android API levels 21-23. Default: false.

globalAttributes Attributes to append to every span collected. For an example, see Manage global attributes.
instrumentedProcessName Compares application ID and process name. If they are the same, the application is visible to user. If not, it is the background process.
spanInterceptor Use this setting to filter or customize spans. For example, you can use (SpanData) -> SpanData? to redact personal identifiable information (PII), remove span attributes, or change the span name. See Filter spans.
session Configured by SessionConfiguration for configuring sessions. It has following properties: samplingRate Activates session ID based sampling and sets a sampling ratio. The sampling ratio is the probability of a session being included between. Values range between 0.0 (all dropped) and 1.0 (all included).
user Configured by UserConfiguration for end user tracking.

It has following properties: trackingMode with supports for two tracking modes:

  • UserTrackingMode.ANONYMOUS_TRACKING: Sends telemetry with an anonymous user ID

  • UserTrackingMode.NO_TRACKING: Does not attach an anonymous user ID

The default is ANONYMOUS_TRACKING.

AgentPreferences

You can set up endpoint configuration for the agent after installation through SplunkRum.instance.preferences, and read the current endpoint configuration using SplunkRum.instance.state , as in the following examples.

Kotlin

Access:

KOTLIN
val preferences = SplunkRum.instance.preferences

Usage:

KOTLIN
// Using realm and token (automatically generates both trace and session replay endpoints)
SplunkRum.instance.preferences.endpointConfiguration = EndpointConfiguration(
    realm = "your-splunk-realm",
    rumAccessToken = "your-splunk-rum-access-token"
)

// Using custom trace endpoint only
SplunkRum.instance.preferences.endpointConfiguration = EndpointConfiguration(
    URL("https://custom-endpoint.example.com/v1/traces")
)

// Using custom endpoints for both traces and session replay
SplunkRum.instance.preferences.endpointConfiguration = EndpointConfiguration(
    URL("https://custom-endpoint.example.com/v1/traces"),
    URL("https://custom-endpoint.example.com/v1/logs")
)

// Clear endpoint configuration
SplunkRum.instance.preferences.endpointConfiguration = null

Read endpoint configuration:

KOTLIN
val currentEndpoint = SplunkRum.instance.state.endpointConfiguration
println("Trace endpoint: ${currentEndpoint?.traceEndpoint}")
println("Session replay endpoint: ${currentEndpoint?.sessionReplayEndpoint}")
Java

Access:

JAVA
AgentPreferences preferences = SplunkRum.getInstance().getPreferences();

Usage:

JAVA
// Using realm and token (automatically generates both trace and session replay endpoints)
SplunkRum.getInstance().getPreferences().setEndpointConfiguration(
    new EndpointConfiguration("your-splunk-realm", "your-splunk-rum-access-token")
);

// Using custom trace endpoint only
SplunkRum.getInstance().getPreferences().setEndpointConfiguration(
    new EndpointConfiguration(new URL("https://custom-endpoint.example.com/v1/traces"))
);

// Using custom endpoints for both traces and session replay
SplunkRum.getInstance().getPreferences().setEndpointConfiguration(
    new EndpointConfiguration(
        new URL("https://custom-endpoint.example.com/v1/traces"),
        new URL("https://custom-endpoint.example.com/v1/logs")
    )
);

// Clear endpoint configuration
SplunkRum.getInstance().getPreferences().setEndpointConfiguration(null);

Read endpoint configuration:

JAVA
EndpointConfiguration currentEndpoint = SplunkRum.getInstance()
    .getState()
    .getEndpointConfiguration();
    
if (currentEndpoint != null) {
    System.out.println("Trace endpoint: " + currentEndpoint.getTraceEndpoint());
    System.out.println("Session replay endpoint: " + currentEndpoint.getSessionReplayEndpoint());
}

UserPreferences

You can set up user tracking for the agent after installation through SplunkRum.instance.user.preferences, and read the current user tracking mode using SplunkRum.instance.user.state, as in the following examples.

Kotlin

Access:

KOTLIN
val preferences = SplunkRum.instance.user.preferences
Usage:
KOTLIN
// Enable anonymous user tracking (default behavior)
SplunkRum.instance.user.preferences.trackingMode = UserTrackingMode.ANONYMOUS_TRACKING

// Disable user tracking
SplunkRum.instance.user.preferences.trackingMode = UserTrackingMode.NO_TRACKIN
Java
Access:
CODE
UserPreferences preferences = SplunkRum.getInstance().getUser().getPreferences();
Usage:
CODE
// Enable anonymous user tracking (default behavior)
SplunkRum.getInstance().getUser().getPreferences().setTrackingMode(UserTrackingMode.ANONYMOUS_TRACKING);

// Disable user tracking
SplunkRum.getInstance().getUser().getPreferences().setTrackingMode(UserTrackingMode.NO_TRACKING);

Instrumentation module settings

You can configure the following modules in the Splunk RUM agent:

Note: A module's settings only take effect if that module is activated (its isEnabled attribute is set to true). All modules except for navigation detection are activated by default.

HTTP instrumentation module

Automatic network instrumentation

The Android RUM agent supports automatic instrumentation for the OkHttp and HttpURLConnection HTTP clients.

  • Okhttp3

    This instrumentation automatically modifies the code at build time and adds the necessary hooks for tracing network requests made through the OkHttp3 APIs. To activate this, add the following plugin to your Android application:

    CODE
    plugins {
      id("com.splunk.rum-okhttp3-auto-plugin") version "2.0.0"
    }
    Note: If you don't add the plugin to the application at build time, the runtime OkHttp3AutoModuleConfiguration will have no effect.
  • HttpUrlConnection

    This instrumentation automatically modifies the code at build time and adds the necessary hooks for tracing network requests made via the URLConnection , HttpURLConnection, or HttpsURLConnection APIs. To enable this, add the following plugin to your Android application.

    CODE
    plugins {
      id("com.splunk.rum-httpurlconnection-auto-plugin") version "2.0.0"
    }
    Note: If you don't add the plugin to the application at build time, the runtime HttpUrlModuleConfiguration will have no effect.
    Note:

    Note: There is currently an open issue with Google that may result in a build failure when an application is built with these plugins. It's related to the Jetifier. The issue is tracked in the Google Issue Tracker and can be resolved by setting the enableJetifier flag to false in your gradle.properties file. For example, android.enableJetifier=false

Manual OkHttp instrumentation
  1. Obtain the instrumented Call.Factory object using the following API:

    Kotlin
    KOTLIN
    // Provide your OkHttpClient to this API to obtain the instrumented Call.Factory 
    val instrumentedCallFactory = SplunkRum.instance.okHttpManualInstrumentation.buildOkHttpCallFactory(okHttpClient)
    Java
    JAVA
    Call.Factory instrumentedCallFactory = OkHttpManualInstrumentation.instance.buildOkHttpCallFactory(okHttpClient);
  2. Use the obtained Call.Factory object (similar to how you would use the OkHttpClient object) to make requests. For example:

    Kotlin
    KOTLIN
    val request = Request.Builder()
        .url("https://publicobject.com/helloworld.txt")
        .build()
    
    instrumentedCallFactory.newCall(request).execute().use { response ->
      if (!response.isSuccessful) throw IOException("Unexpected code $response")
    
      for ((name, value) in response.headers) {
        println("$name: $value")
      }
    
      println(response.body?.string())
    }
    Java
    JAVA
    Request request = new Request.Builder()
            .url("https://publicobject.com/helloworld.txt")
            .build();
    
    Call call = instrumentedCallFactory.newCall(request);
    
    Response response = null;
    try {
        response = call.execute();
    
        if (!response.isSuccessful()) {
            throw new IOException("Unexpected code " + response);
        }
    
        // Print all response headers
        Headers headers = response.headers();
        for (int i = 0; i < headers.size(); i++) {
            System.out.println(headers.name(i) + ": " + headers.value(i));
        }
    
        // Print response body
        if (response.body() != null) {
            System.out.println(response.body().string());
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
Capture request and response headers

You can opt-in to capture certain request and response headers using the HTTP instrumentation module. If those headers are available, the resulting span will contain http.request.header.<key> and http.response.header.<key> attributes with the header value(s). See OkHttp3ManualModuleConfiguration , HttpURLModuleConfiguration or OkHttp3AutoModuleConfiguration below for examples.

Kotlin
KOTLIN
class App : Application() {

    override fun onCreate() {
        super.onCreate()

        val agent = SplunkRum.install(
            application = this,
            agentConfiguration = AgentConfiguration(
                endpoint = EndpointConfiguration(
                    realm = "your-splunk-realm",
                    rumAccessToken = "your-splunk-rum-access-token"
                ),
                appName = "your-app-name",
                deploymentEnvironment = "your-environment-name"
            ),
            moduleConfigurations = arrayOf( 
                // Instruments HttpUrlConnection requests and responses.
                // isEnabled = true to enable instrumentation.
                // capturedRequestHeaders / capturedResponseHeaders lists the headers to capture.
                HttpURLModuleConfiguration(
                    isEnabled = true,
                    capturedRequestHeaders = listOf("Host", "Accept"),
                    capturedResponseHeaders = listOf("Date", "Content-Type", "Content-Length")
                ),

                // Instruments OkHttp3 automatically.
                // isEnabled = true to enable auto-instrumentation.
                // capturedRequestHeaders / capturedResponseHeaders lists the headers to capture.
                OkHttp3AutoModuleConfiguration(
                    isEnabled = true,
                    capturedRequestHeaders = listOf("User-Agent", "Accept"),
                    capturedResponseHeaders = listOf("Date", "Content-Type", "Content-Length")
                ),

                // Instruments OkHttp3 manually.
                // capturedRequestHeaders / capturedResponseHeaders lists the headers to capture.
                OkHttp3ManualModuleConfiguration(
                    capturedRequestHeaders = listOf("Content-Type", "Accept"),
                    capturedResponseHeaders = listOf("Server", "Content-Type", "Content-Length")
                )
            )
        )
    }
}
Java
JAVA
public class App extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        SplunkRum agent = SplunkRum.install(
            this,
            new AgentConfiguration(
                new EndpointConfiguration(
                    "your-splunk-realm",
                    "your-splunk-rum-access-token"
                ),
                "your-app-name",
                "your-environment-nameironment"
            ),

            // Instruments HttpUrlConnection requests and responses.
            new HttpURLModuleConfiguration(
                true,
                Arrays.asList("Host", "Accept"),
                Arrays.asList("Date", "Content-Type", "Content-Length")
            ),

            // Instruments OkHttp3 automatically.
            new OkHttp3AutoModuleConfiguration(
                true,
                Arrays.asList("User-Agent", "Accept"),
                Arrays.asList("Date", "Content-Type", "Content-Length")
            ),

            // Instruments OkHttp3 manually.
            new OkHttp3ManualModuleConfiguration(
                Arrays.asList("Content-Type", "Accept"),
                Arrays.asList("Server", "Content-Type", "Content-Length")
            )
        );
    }
}
Note: This section describes how to activate automatic detection. To activate manual detection, see Manually track navigation events. You can activate both automatic and manual detection to track built-in and custom events.

By default, NavigationModuleConfiguration:isEnabled is set to true. However, automatic detection is deactivated by default. See the following section to activate automatic detection.

Track navigation events automatically

Automatic detection of screen names is deactivated by default. You can activate it through the isAutomatedTrackingEnabled setting as shown in the examples below.

When isAutomatedTrackingEnabled is set to true, the SDK infers the current screen from resumed activities and fragments. Fragments take precedence over the hosting activity. The module ignores NavHostFragment, DialogFragment, and screens marked with @NavigationElement(isIgnored = true).

Kotlin
KOTLIN
class App : Application() {
 
    override fun onCreate() {
        super.onCreate()
 
        val agent = SplunkRum.install(
            application = this,
            agentConfiguration = AgentConfiguration(
                endpoint = EndpointConfiguration(
                    realm = "your-splunk-realm",
                    rumAccessToken = "your-splunk-rum-access-token"
                ),
                appName = "your-app-name",
                deploymentEnvironment = "your-environment-name"
            ),
            moduleConfigurations = arrayOf(
                // Tracks navigation for activities and fragments.
                // isEnabled = true to enable navigation tracking.
                // isAutomatedTrackingEnabled = false disables automated tracking.
                NavigationModuleConfiguration(
                    isEnabled = true,
                    isAutomatedTrackingEnabled = true,
                    // optional: navigationEventProcessor = NavigationEventProcessor() — when you need to transform/filter events
                )
            )
        )
    }
}
Java
JAVA
public class App extends Application {
 
    @Override
    public void onCreate() {
        super.onCreate();
 
        SplunkRum agent = SplunkRum.install(
            this,
            new AgentConfiguration(
                new EndpointConfiguration(
                    "your-splunk-realm",
                    "your-splunk-rum-access-token"
                ),
                "your-app-name",
                "your-environment-name"
            ),
            // Tracks screen names
            new NavigationModuleConfiguration(
              true,
              true,
            // optional: NavigationEventProcessor — when you need to transform/filter events  
            )
        );
    }
}
Jetpack Compose navigation tracking

For apps using Jetpack Navigation with Compose, the SDK tracks route changes automatically once you register your NavController.

After SplunkRum.install(...), register the controller where it is created, typically next to NavHost:

Kotlin
KOTLIN
val navController = rememberNavController()
SplunkRum.instance.navigation.registerNavController(navController)

NavHost(navController = navController, startDestination = "home") {
    composable("home") { HomeScreen(navController) }
    composable("profile/{userId}") { ProfileScreen(navController) }
}
Java
JAVA
Navigation.getInstance().registerNavController(navController);
Call unregisterNavController when the controller is no longer in use (Kotlin):
KOTLIN
SplunkRum.instance.navigation.unregisterNavController(navController)
Navigation event processor

NavigationEventProcessor lets you transform or suppress Jetpack Compose navigation events before emission. Pass this processor with NavigationModuleConfiguration.

The following code blocks show examples of using the navigation event processor.

Rename routes to friendly names (Kotlin):
KOTLIN
NavigationModuleConfiguration(
    isEnabled = true,
    isAutomatedTrackingEnabled = true,
    navigationEventProcessor = NavigationEventProcessor { event ->
        when (event.name) {
            "profile/{userId}" -> event.also { it.name = "Profile" }
            "search?query={query}" -> event.also { it.name = "Search" }
            else -> event
        }
    }
)
Rename routes (Java):
JAVA
new NavigationModuleConfiguration(
        true,
        true,
        event -> {
            if ("profile/{userId}".equals(event.getName())) {
                event.setName("Profile");
            }
            return event;
        }
);

Suppress a route:

Kotlin
KOTLIN
NavigationModuleConfiguration(
    isEnabled = true,
    isAutomatedTrackingEnabled = true,
    navigationEventProcessor = NavigationEventProcessor { event ->
        if (event.name.startsWith("admin/")) null else event
    }
)
Java
JAVA
new NavigationModuleConfiguration(
        true,
        true,
        event -> event.getName().startsWith("admin/") ? null : event
);

Add custom attributes:

Kotlin
KOTLIN
NavigationModuleConfiguration(
    isEnabled = true,
    isAutomatedTrackingEnabled = true,
    navigationEventProcessor = NavigationEventProcessor { event ->
        event.attributes["business.flow"] = "checkout"
        event
    }
)
Java
JAVA
new NavigationModuleConfiguration(
        true,
        true,
        event -> {
            event.getAttributes().put("business.flow", "checkout");
            return event;
        }
);

Tag routes by section:

Kotlin
KOTLIN
NavigationModuleConfiguration(
    isEnabled = true,
    isAutomatedTrackingEnabled = true,
    navigationEventProcessor = NavigationEventProcessor { event ->
        when {
            event.name.startsWith("settings") -> event.attributes["section"] = "settings"
            event.name.startsWith("profile") -> event.attributes["section"] = "account"
        }
        event
    }
)
Java
JAVA
new NavigationModuleConfiguration(
        true,
        true,
        event -> {
            if (event.getName().startsWith("settings")) {
                event.getAttributes().put("section", "settings");
            } else if (event.getName().startsWith("profile")) {
                event.getAttributes().put("section", "account");
            }
            return event;
        }
);

Jetpack Compose navigation tracking has the following behavior:

  • The route definition is used for the screen.name attribute (e.g. profile/{userId}), not the resolved URL. Route parameter values like the value of userId are included as separate attributes.

  • Structural destinations such as navigation graphs and dialogs are ignored. Only actual screen destinations generate events.

  • If a destination belongs to a nested navigation graph, the parent graph's route is included as the nav.graph attribute.

  • Only one NavController can be registered at a time. Registering a new NavController replaces the previous one. Re-registering the same one again has no effect.

Track navigation events manually

See Manually track navigation events.

To set the screen name yourself, call the manual Navigation.track API in Java or SplunkRum.instance.navigation.track API in Kotlin. Manual detection is useful for custom flows, Compose without a registeredNavController, or whenever automatic detection does not match how you define a screen.

Kotlin
KOTLIN
import com.splunk.rum.integration.navigation.extension.navigation
import io.opentelemetry.api.common.AttributeKey
import io.opentelemetry.api.common.Attributes

// Screen name only
SplunkRum.instance.navigation.track("ProductDetails")

// With optional attributes
SplunkRum.instance.navigation.track(
    "Checkout",
    Attributes.of(
        AttributeKey.stringKey("flow"),
        "express"
    )
)
Java
JAVA
import com.splunk.rum.integration.navigation.Navigation;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;

// Screen name only
Navigation.getInstance().track("ProductDetails");

// With optional attributes
Attributes attrs = Attributes.of(
        AttributeKey.stringKey("flow"),
        "express"
);
Navigation.getInstance().track("Checkout", attrs);

Crash reporting module

The crash reporting module is included in the new Splunk RUM agent and is activated by default. No additional steps are needed to activate crash reporting. If you want to deactivate crash reporting, see an example below on settings.

Kotlin
KOTLIN
class App : Application() {

    override fun onCreate() {
        super.onCreate()

        val agent = SplunkRum.install(
            application = this,
            agentConfiguration = AgentConfiguration(
                endpoint = EndpointConfiguration(
                    realm = "your-splunk-realm",
                    rumAccessToken = "your-splunk-rum-access-token"
                ),
                appName = "your-app-name",
                deploymentEnvironment = "your-environment-name"
            ),
            moduleConfigurations = arrayOf( 
                // Reports application crashes.
                // isEnabled = false to disable crash reporting.
                CrashModuleConfiguration(
                    isEnabled = false
                )
            )
        )
    }
}
Java
JAVA
public class App extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        SplunkRum agent = SplunkRum.install(
            this,
            new AgentConfiguration(
                new EndpointConfiguration(
                    "your-splunk-realm",
                    "your-splunk-rum-access-token"
                ),
                "your-app-name",
                "your-environment-name"
            ),

            // Disables application crashes.
            new CrashModuleConfiguration(false)
        );
    }
}

Application not responding module

Application not responding (ANR) occurs when an Android application's main thread is blocked for more than five seconds, preventing it from processing user input. The detection of ANRs is activated by default. You can deactivate it by setting AnrModuleConfiguration to false as shown in the examples below.

Kotlin
KOTLIN
class App : Application() {

    override fun onCreate() {
        super.onCreate()

        val agent = SplunkRum.install(
            application = this,
            agentConfiguration = AgentConfiguration(
                endpoint = EndpointConfiguration(
                    realm = "your-splunk-realm",
                    rumAccessToken = "your-splunk-rum-access-token"
                ),
                appName = "your-app-name",
                deploymentEnvironment = "your-environment-name"
            ),
            moduleConfigurations = arrayOf( 
                // Reports ANR (Application Not Responding) events.
                // isEnabled = false to disable ANR reporting.
                AnrModuleConfiguration(
                    isEnabled = false
                )
            )
        )
    }
}
Java
JAVA
public class App extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        SplunkRum agent = SplunkRum.install(
            this,
            new AgentConfiguration(
                new EndpointConfiguration(
                    "your-splunk-realm",
                    "your-splunk-rum-access-token"
                ),
                "your-app-name",
                "your-environment-name"
            ),

            // Disables ANR (Application Not Responding) events.
            new AnrModuleConfiguration(false)
        );
    }
}

Slow rendering module

The slow rendering module is activated by default. You can configure its frame detection interval as shown in the examples below. See what attributes are included when this module is activated.

Kotlin
KOTLIN
class App : Application() {

    override fun onCreate() {
        super.onCreate()

        val agent = SplunkRum.install(
            application = this,
            agentConfiguration = AgentConfiguration(
                endpoint = EndpointConfiguration(
                    realm = "your-splunk-realm",
                    rumAccessToken = "your-splunk-rum-access-token"
                ),
                appName = "your-app-name",
                deploymentEnvironment = "your-environment-name"
            ),
            moduleConfigurations = arrayOf( 
                 // Detects slow or frozen rendering frames.
                // isEnabled = true to enable detection.
                // interval sets the frame detection interval.
                SlowRenderingModuleConfiguration(
                    isEnabled = true,
                    interval = Duration.ofMillis(500)
                )
            )
        )
    }
}
Java
JAVA
public class App extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        SplunkRum agent = SplunkRum.install(
            this,
            new AgentConfiguration(
                new EndpointConfiguration(
                    "your-splunk-realm",
                    "your-splunk-rum-access-token"
                ),
                "your-app-name",
                "your-environment-name"
            ),

            // Detects slow or frozen rendering frames.
            new SlowRenderingModuleConfiguration(true, Duration.ofMillis(500))
        );
    }
}

Interaction detection module

Interaction detection is enabled by default. You can deactivate it by setting the isEnabled parameter as in the examples below.

Kotlin
KOTLIN
class App : Application() {

    override fun onCreate() {
        super.onCreate()

        val agent = SplunkRum.install(
            application = this,
            agentConfiguration = AgentConfiguration(
                endpoint = EndpointConfiguration(
                    realm = "your-splunk-realm",
                    rumAccessToken = "your-splunk-rum-access-token"
                ),
                appName = "your-app-name",
                deploymentEnvironment = "your-environment-name"
            ),
            moduleConfigurations = arrayOf( 
                // Tracks user interactions.
                // isEnabled = false to disable interaction tracking.
                InteractionsModuleConfiguration(
                    isEnabled = false
                )
            )
        )
    }
}
Java
JAVA
public class App extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        SplunkRum agent = SplunkRum.install(
            this,
            new AgentConfiguration(
                new EndpointConfiguration(
                    "your-splunk-realm",
                    "your-splunk-rum-access-token"
                ),
                "your-app-name",
                "your-environment-name"
            ),

            // Disable user interactions.
            new InteractionsModuleConfiguration(false),
        );
    }
}

Application lifecycle monitoring module

The application lifecycle monitoring module is included in the new Splunk RUM agent and is activated by default. To deactivate application lifecycle monitoring, see examples below.

Tip: See the activity/fragment lifecycle and attributes that are included when this module is activated.
Kotlin
KOTLIN
class App : Application() {

    override fun onCreate() {
        super.onCreate()

        val agent = SplunkRum.install(
            application = this,
            agentConfiguration = AgentConfiguration(
                endpoint = EndpointConfiguration(
                    realm = "your-splunk-realm",
                    rumAccessToken = "your-splunk-rum-access-token"
                ),
                appName = "your-app-name",
                deploymentEnvironment = "your-environment-name"
            ),
            moduleConfigurations = arrayOf( 
                // Reports application crashes
                // isEnabled = false to disable application lifecycle detection
                ApplicationLifecycleModuleConfiguration(
                    isEnabled = false
                )
            )
        )
    }
}
Java
JAVA
class App : Application() {

    override fun onCreate() {
        super.onCreate()

        val agent = SplunkRum.install(
            application = this,
            agentConfiguration = AgentConfiguration(
                endpoint = EndpointConfiguration(
                    realm = "your-splunk-realm",
                    rumAccessToken = "your-splunk-rum-access-token"
                ),
                appName = "your-app-name",
                deploymentEnvironment = "your-environment-name"
            ),
            moduleConfigurations = arrayOf( 
                // Reports application crashes
                // isEnabled = false to disable application lifecycle detection
                ApplicationLifecycleModuleConfiguration(
                    isEnabled = false
                )
            )
        )
    }
}

Activity/fragment lifecycle monitoring module

The activity/fragment lifecycle module records activity and fragment lifecycle transitions and sends them as RUM lifecycle telemetry.

The activity/fragment lifecycle module is activated by default. You can deactivate it by setting the isEnabled flag to false.

allowedEvents is a Set<LifecycleAction> that acts as an allow list; only those transitions are emitted. allowedEvents defaults to LifecycleModuleConfiguration.MAIN_LIFECYCLE_EVENTS (main transitions, no pre/post). Use the module presets or your own set to reduce noise or to opt into extra detail.

Configure the module

The following code example shows how to configure the activity/fragment lifecycle monitoring module and includes an example of enabling all Lifecycle events.

You can optionally pass any preset or a custom setOf(...) (or Set in Java) for allowedEvents. For example, only RESUMED and PAUSED for minimal traffic or ALL_LIFECYCLE_EVENTS for deep debugging.

Kotlin
KOTLIN
class App : Application() {

    override fun onCreate() {
        super.onCreate()

        val agent = SplunkRum.install(
            application = this,
            agentConfiguration = AgentConfiguration(
                endpoint = EndpointConfiguration(
                    realm = "your-splunk-realm",
                    rumAccessToken = "your-splunk-rum-access-token"
                ),
                appName = "your-app-name",
                deploymentEnvironment = "your-environment-name"
            ),
            moduleConfigurations = arrayOf( 
              
        // isEnabled defaults to true; allowedEvents defaults to MAIN_LIFECYCLE_EVENTS.
        // Here we only emit ALL lifecycle events (main + pre/post (API 29+)). Other examples:
        //   LifecycleModuleConfiguration()  // defaults
        //   LifecycleModuleConfiguration(isEnabled = false)  // module off
        //   allowedEvents = setOf(LifecycleAction.RESUMED, LifecycleAction.PAUSED)  resumed/paused (minimal volume)
                LifecycleModuleConfiguration(
                    isEnabled = true,
                    allowedEvents = LifecycleModuleConfiguration.ALL_LIFECYCLE_EVENTS
                )
            )
        )
    }
}
Java
JAVA
import android.app.Application;
import com.splunk.rum.integration.agent.api.AgentConfiguration;
import com.splunk.rum.integration.agent.api.EndpointConfiguration;
import com.splunk.rum.integration.agent.api.SplunkRum;
import com.splunk.rum.integration.lifecycle.LifecycleModuleConfiguration;

public class App extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        SplunkRum agent = SplunkRum.install(
                this,
                new AgentConfiguration(
                        new EndpointConfiguration(
                                "your-splunk-realm",
                                "your-splunk-rum-access-token"
                        ),
                        "your-app-name",
                        "your-environment-name"
                ),
                // isEnabled defaults to true; allowedEvents defaults to MAIN_LIFECYCLE_EVENTS.
                // Here we only emit ALL lifecycle events (main + pre/post (API 29+)). Other examples:
                //   new LifecycleModuleConfiguration()  // defaults
                //   new LifecycleModuleConfiguration(false)  // module off
                //   new LifecycleModuleConfiguration(true, setOfResumedPaused)  // resumed/paused (minimal volume) — build a Set with RESUMED, PAUSED
                new LifecycleModuleConfiguration(
                        true,
                        LifecycleModuleConfiguration.Companion.getALL_LIFECYCLE_EVENTS()
                )
        );
    }
}
Module presets

The following table describes the activity/fragment lifecycle module presets, their contents, and how to use them.

Preset What it contains Use case
MAIN_LIFECYCLE_EVENTS(default) Core activity and fragment transitions: created, started, resumed, paused, stopped, destroyed, plus fragment attached, view_created, view_destroyed, detached. Default balance of signal vs. volume.
PRE_POST_LIFECYCLE_EVENTS Only pre_* and post_* activity callbacks (and pre_attached for fragments). Emitted on API 29+ where those callbacks exist. Extra granularity around each main transition.
ALL_LIFECYCLE_EVENTS EveryLifecycleAction, i.e. main + pre/post (same as combining the two sets above). Full diagnostic detail; highest volume.
After the module is activated, the session details page displays activity and fragment lifecycle events as shown in the following screenshot.

The RUM session replay view with activity/fragment lifecycle events.