Configure the Splunk RUM React Native agent (old agent)
Configure the Splunk Distribution of OpenTelemetry for React Native.
You can configure the Splunk Distribution of OpenTelemetry for React Native to add custom attributes, adapt the instrumentation to your environment and application, and more.
To configure the React Native RUM agent, add the key-value pairs to a ReactNativeConfiguration object. For example:
const RumConfig: ReactNativeConfiguration = {
realm: 'your-splunk-realm',
rumAccessToken: 'your-splunk-rum-access-token',
applicationName: 'your-app-name',
environment: 'your-environment',
debug: true,
/**
* URLs that partially match any regex in ignoreUrls aren't traced.
* URLs that are exact matches of strings in ignoreUrls aren't traced.
*/
ignoreUrls: ['http://sampleurl.org'],
}
General settings
Use the following properties in the ReactNativeConfiguration object:
|
Option |
Description |
|---|---|
|
|
Ingest URL to which the agent sends collected telemetry. The URL must contain your realm in Splunk Observability Cloud. Example: |
|
|
Activates debug logging. Default: |
|
|
Environment for all the spans produced by the application. Example: |
endpointConfiguration |
Sets the configuration needed to export data to an endpoint. There are two required inputs:
You don't have to configure endpoints at installation time; you can configure them later using |
|
|
Sets additional attributes added to all spans. Attributes are defined as an array of comma-separated key-value pairs. Example: |
|
|
Regular expression pattern that matches URLs you want to ignore when reporting HTTP activity. |
|
|
RUM token that authorizes the agent to send telemetry data to Splunk Observability Cloud. To generate a RUM access token, see Generate your RUM access token in Splunk Observability Cloud. |
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.
Access:
const preferences = SplunkRum.instance.preferences;
// Using realm and token
await SplunkRum.instance.preferences.setEndpointConfiguration({
realm: 'your-splunk-realm',
rumAccessToken: 'your-splunk-rum-access-token',
});
// Using custom trace endpoint only
await SplunkRum.instance.preferences.setEndpointConfiguration({
trace: 'https://custom-endpoint.example.com/v1/traces',
});
// Using custom endpoints for both traces and session replay
await SplunkRum.instance.preferences.setEndpointConfiguration({
trace: 'https://custom-endpoint.example.com/v1/traces',
sessionReplay: 'https://custom-endpoint.example.com/v1/logs',
});
// Clear endpoint configuration
await SplunkRum.instance.preferences.setEndpointConfiguration(null);
// Read endpoint configuration
const state = await SplunkRum.instance.getState();
const endpoint = state.endpoint;
if (endpoint && 'trace' in endpoint) {
console.log(`Trace endpoint: ${endpoint.trace}`);
console.log(`Session replay endpoint: ${endpoint.sessionReplay}`);
} else if (endpoint && 'realm' in endpoint) {
console.log(`Realm: ${endpoint.realm}`);
}