Skip to main content

Configuration options

Instrumentation's​

Turn on/off specific instrumentation; defaults to true for all. Each instrumentation is responsible for which data the SDK will track and collect for you.

await CoralogixRum.init({
// ...
instrumentations: {
errors: true,
custom: true,
mobile_vitals: true,
anr: true,
lifecycle: true,
user_interaction: true,
network: true
},
});
Note

The network instrumentation also injects the W3C traceparent header. Setting network to false stops trace context propagation as well, even when traceParentInHeader is enabled.

Mobile vital detectors​

Disable specific mobile vitals detection and collection

await CoralogixRum.init({
// ...
mobileVitals: {
warm: true,
cold: true,
cpu: true,
memory: true,
rendering: true,
slowFrozenFrames: true,
}
});

Cold start​

Two cold-start values are reported per user-visible launch:

  • cold — measured by the native SDK: process start to the first native frame.
  • cold_hybrid — measured by the plugin: process start to the first frame with React content on screen. This is the launch time your users actually see, so it is always at least cold.

Setting mobileVitals.cold (or instrumentations.mobile_vitals) to false disables both. Launches that start in the background (headless JS, background fetch, push) and prewarmed iOS launches do not report cold_hybrid.

Note

On Android, cold_hybrid is not reported in bridgeless mode (the New Architecture default since React Native 0.74): React Native only emits the content-appeared marker it relies on when the app runs with the bridge.

Exclude from sampling​

By default, when a session is sampled out (via sessionSampleRate), none of its RUM events are reported, unless alwaysTrackSessionsWithErrors keeps it for an error. Use excludeFromSampling to keep reporting specific event categories even when the session is sampled out.

import { CoralogixRum } from '@coralogix/react-native-plugin';

await CoralogixRum.init({
// ...
sessionSampleRate: 10,
excludeFromSampling: ['errors', 'logs'], // always emitted, even for sampled-out sessions
});

Allowed values: 'errors', 'logs', 'network', 'userInteractions', 'mobileVitals', 'customSpan', 'customMeasurement', 'navigation', and 'lifecycle'. 'navigation' and 'lifecycle' are available from version 0.15.0. These are the same values the native iOS and Android SDKs accept. The plugin ignores an unrecognized value and logs a warning that names it.

excludeFromSampling only affects sampled-out sessions; a sampled-in session reports everything that is enabled. It never re-enables an instrumentation you turned off in instrumentations: with instrumentations: { network: false }, listing 'network' here has no effect.

Listing anything here also brings back the SDK's own internal events — the initialization event, and session_replay_init when Session Replay starts — for that sampled-out session. Leave the list empty and the session reports nothing at all, unless alwaysTrackSessionsWithErrors is on.

Inside a beforeSend callback, session_context.isSessionSampledIn tells you whether an event came from a sampled-in session or reached you only via excludeFromSampling, so excluded categories can be filtered further.

Sessions with errors​

Set alwaysTrackSessionsWithErrors: true to keep a session that sessionSampleRate leaves out instead of dropping it. Its events stay on the device until an error is reported in it. Then everything it kept is sent, and the rest of the session is reported as it happens. A session that ends without an error sends nothing.

To hold every sampled-in session the same way, set onlyWithErrorConfig.enable to true.

import { CoralogixRum } from '@coralogix/react-native-plugin';

await CoralogixRum.init({
// ...
sessionSampleRate: 10,
alwaysTrackSessionsWithErrors: true,
onlyWithErrorConfig: {
maxRumEvents: 5000,
instrumentationsToSend: ['mobileVitals'],
},
});

onlyWithErrorConfig fields:

FieldTypeDescription
enablebooleanHolds every sampled-in session until an error. Defaults to false.
maxRumEventsnumberHow many events a session keeps while it waits for an error. Past this, what it kept is discarded and it starts again. Defaults to 5000, at most 20000; 0 or less uses the default.
instrumentationsToSendExcludableInstrumentation[]Categories sent at once instead of being held. Accepts the same values as excludeFromSampling. Defaults to [].

What to expect:

  • An event with error severity sends the session. reportError, uncaught JavaScript errors, and console.error calls are all reported as errors, so each of them sends it. To keep noise such as a known console.error message from sending a session, list it in ignoreErrors.
  • While a session is held, excludeFromSampling sends nothing early. Use instrumentationsToSend for that.
  • Every event carries session_context.onlyWithErrorMode, true in a held session. Events sent from the error on also carry session_context.hasError: true. Both are read-only, and hasError is set after beforeSend runs, so a beforeSend callback never sees it.
Warning

A beforeSend that drops events from sampled-out sessions also drops the events a session keeps for an error, so the session does not arrive whole.

Ignore errors​

The ignoreErrors option allows you to exclude errors that meet specific criteria. Pass strings. Each string is a case-insensitive regular expression matched against the error message, so escape characters such as ( and . to match them literally. On Android a string must match the whole message, while on iOS it can match part of it; to match part of a message on both, wrap it in .*. A JavaScript RegExp is not applied.

import { CoralogixRum } from '@coralogix/react-native-plugin';

await CoralogixRum.init({
// ...
ignoreErrors: ['Exact match error message', '.*partial match.*'],
});

TraceParentInHeader​

Add trace context propagation in headers across service boundaries

await CoralogixRum.init({
// ...
traceParentInHeader: {
enabled: true
},
});
Note

The traceparent header is added by the network instrumentation, so this feature depends on it. If you set instrumentations.network to false, no trace headers are sent even with enabled: true.

From version 0.15.0, the trace flags at the end of traceparent follow the session's sampling decision, on iOS and Android alike:

  • 01 (sampled) when the session is sampled in, when it is held for an error (see Sessions with errors), or when it is sampled out and excludeFromSampling includes 'network'.
  • 00 (not sampled) when the session is sampled out, not held for an error, and 'network' is not excluded.

A request that starts before CoralogixRum.init completes carries no traceparent header.

If your Android app doesn't apply the Coralogix Gradle plugin, the plugin adds the header from JavaScript. Each fetch that gets a traceparent then waits up to 500 ms for the native SDK's sampling decision, and goes out without the header if the decision doesn't arrive in time. To keep that wait off requests you don't need to trace, list only your own services in traceParentInHeader.options.allowedTracingUrls.

Last updated on