Docs » Supported integrations in Splunk Observability Cloud » Instrument mobile and web applications for Splunk RUM » Instrument Android applications for Splunk RUM » Configure the Splunk Android RUM instrumentation

Configure the Splunk Android RUM instrumentation 🔗

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

To configure the Android RUM agent, pass the settings by preparing a Config instance using the fluent builder API. The following example shows how to configure the RUM token, Splunk realm, and application name:

class MyApplication extends Application {
   private final String realm = "<realm>";
   private final String rumAccessToken = "<your_RUM_access_token>";

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

   SplunkRum.builder()
         .setApplicationName("<name_of_app>")
         .setRealm("<realm>"")
         .setRumAccessToken("<rumAccessToken>")
         .build(this);
   }
}

General settings 🔗

Use the following settings to configure the Android RUM agent:

Option

Description

setRumAccessToken(String)

RUM token that authorizes the agent to send telemetry to Splunk Observability Cloud. To generate a RUM access token, see Generate your RUM access token in Splunk Observability Cloud.

setRealm(String)

Realm in Splunk Observability Cloud, used to generate the endpoint URL. For example, us0.

setBeaconEndpoint(String)

Use this method instead of setRealm(String) to provide the full URL of the RUM ingest endpoint. For example, https://rum-ingest.<realm>.signalfx.com/v1/rum.

setApplicationName(String)

Sets the name of the application.

setDeploymentEnvironment(String)

Sets the environment attribute on the spans that are generated by the instrumentation.

setGlobalAttributes(Attributes)

Attributes to append to every span collected. For an example, see Manage global attributes.

filterSpans(Consumer<SpanFilterBuilder>)

Use this setting to filter or customize spans. For example, you can use filterSpans to redact personal identifiable information (PII), remove span attributes, or change the span name. See Filter spans.

enableDiskBuffering()

Activates storage-based buffering of telemetry. This setting is useful when instrumenting applications that might work offline for extended periods of time.

limitDiskUsageMegabytes(int)

Sets the maximum amount of storage to use for disk buffering. The default value is 25 MB. Requires diskBufferingEnabled to be true.

enableSessionBasedSampling(double)

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).

enableDebug()

Activates debug mode. This feature is inactive by default. Activating debug mode activates the OpenTelemetry logging span exporter, which might be useful when debugging instrumentation issues.

enableExperimentalOtlpExporter()

Activates the experimental OTLP exporter. The exporter is not compatible with disk buffering.

Instrumentation settings 🔗

Use the following settings to activate or deactivate the collection of specific data:

Option

Description

disableSubprocessInstrumentation()

Deactivates instrumentation for application subprocesses. Accepts an application ID value.

enableBackgroundInstrumentationDeferredUntilForeground()

Enables the deferrment of background telemetry until the app is foregrounded. Used to connect background session data to a real user session.

disableCrashReporting()

Deactivates crash reporting. This feature is activated by default.

disableAnrDetection()

Deactivates ANR (Application not responding) detection and reporting. This feature is activated by default.

disableNetworkMonitor()

Deactivates network monitoring. This feature is activated by default.

disableSlowRenderingDetection()

Deactivates the detection of slow frame renders. This feature is activated by default. Splunk RUM defines renders as slow or frozen following the Android Vitals definition of the Android Developers documentation.

setSlowRenderingDetectionPollInterval(Duration)

Sets the default polling interval for slow or frozen render detection. The default value is 1000 milliseconds. The value must be positive.

HTTP instrumentation settings 🔗

The Android RUM agent includes instrumentation for the OkHttp and Volley HTTP clients.

OkHttp 🔗

Instrument OkHttp using the Call.Factory wrapper, as in the following example:

private Call.Factory buildOkHttpClient(SplunkRum splunkRum) {
   return splunkRum.createRumOkHttpCallFactory(new OkHttpClient());
}

Volley HTTP (Experimental) 🔗

To instrument Volley HTTP, add the splunk-otel-android-volley dependency to the build.gradle.kts file:

dependencies {
   //...
   implementation("com.splunk:splunk-otel-android-volley:+")
   //...
}

Use the VolleyTracing class to create an instance of VolleyTracing, as in the following example:

VolleyTracing volleyTracing = VolleyTracing.builder(splunkRum).build();

The following example shows how to retrieve an instance of HurlStack from your volleyTracing instance:

HurlStack hurlStack = volleyTracing.newHurlStack();

You can then use the hurlStack instance to create your request queue and send requests as usual.

Capture additional request and response headers 🔗

You can capture additional request and response headers using the HTTP instrumentations. Additional headers appear with the http.request.header. and http.response.header. prefixes.

To capture additional headers, provide the builder with a list of headers to catch. For example:

builder.setCapturedRequestHeaders(asList("X-My-Custom-Request-Header"))
builder.setCapturedResponseHeaders(asList("X-My-Custom-Response-Header"))

The resulting span contains an http.request.header.x_my_custom_header attribute with one or more header values.

This page was last updated on May 14, 2024.