Configuration options
CoralogixExporterOptions Reference
The fields accepted by CoralogixExporterOptions. Each one is described in detail in the sections below.
| Property | Type | Description | Required |
|---|---|---|---|
| coralogixDomain | CoralogixDomain | The Coralogix domain for your account's region. | Yes |
| publicKey | String | Coralogix token, the publicly-visible public_key value. | Yes |
| environment | String | Specifies the environment, such as development, staging, or production. | Yes |
| application | String | Name of the application. | Yes |
| version | String | Version of the application. | Yes |
| userContext | UserContext? | Configuration for user context. | No |
| debug | Bool | Turns internal debug logging on or off. | No |
| ignoreUrls | [String]? | URLs that partially match any regex in ignoreUrls are not traced. | No |
| ignoreErrors | [String]? | Patterns for error messages that should not be sent to Coralogix. | No |
| labels | [String: Any]? | Labels added to every span. | No |
| beforeSend | (([String: Any]) -> [String: Any]?)? | Callback to inspect, modify, or discard each event before it reaches Coralogix. Receives the event as a dictionary; return nil to drop it. | No |
| tracesExporter | TracesExporterCallback?, i.e. ((CoralogixTraceExporterData) throws -> Void)? | Callback invoked for each exported span batch, for forwarding spans to your own collector. | No |
| networkExtraConfig | [NetworkCaptureRule]? | Per-URL rules for capturing request and response headers and payloads. Nothing is captured by default. Only allowlist URLs and header names you are comfortable logging, and note that bodies over 1024 characters are dropped rather than truncated. See "Swizzling and network capture" for the full rules. | No |
| proxyUrl | String? | Routes all RUM data through a proxy URL. | No |
| traceParentInHeader | [String: Any]? | Configures W3C traceparent header propagation for distributed tracing. | No |
| collectIPData | Bool | Sends the client IP for region detection. Defaults to true. | No |
| sessionSampleRate | Int | Percentage of overall sessions tracked, 0–100. Defaults to 100. | No |
| excludeFromSampling | Set<ExcludableInstrumentation> | Instrumentations that bypass the sessionSampleRate gate, so their events are sent even from sessions that are not sampled in. Accepts errors, logs, network, userInteractions, mobileVitals, customSpan and customMeasurement. Defaults to empty. | No |
| enableSwizzling | Bool | Method swizzling for URLSession instrumentation. Defaults to true. | No |
| instrumentations | [InstrumentationType: Bool]? | Switches individual instrumentations off. All are active by default. Read once while the SDK initializes, so a later change takes effect only after shutdown() and a fresh CoralogixRum(options:). | No |
| mobileVitals | [MobileVitalsType: Bool]? | Switches individual mobile vitals detectors off. All are active by default. Read at initialization only, the same as instrumentations. | No |
| shouldSendText | ((UIView, String) -> Bool)? | Called before recording tapped text. Return false to redact it: the field is still sent, carrying *** instead of the text. Taps that land on masked geometry, inside a masked subtree, or on a field carrying sensitive traits are redacted without consulting this closure. Text masked only in the replay's pixels still reaches it, so use this closure for anything you need kept out of events. | No |
| resolveTargetName | ((UIView) -> String?)? | Returns a human-readable name for a tapped view, used as target_element. Return nil to fall back to the class name. Runs on the main thread on every tap, so keep it fast. | No |
Instrumentations
Turn on/off specific instrumentation, default to true. Each instrumentation is responsible for which data the SDK will track and collect for you.
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
instrumentations: [.mobileVitals: true,
.custom: true,
.errors: true,
.network: true,
.userActions: false,
.anr: true,
.lifeCycle: false])
Ignore Errors
The ignoreErrors option allows you to exclude errors that meet specific criteria. This option accepts a set of strings and regular expressions to match against the event's error message. Use regular expressions for exact matching as strings remove partial matches.
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
ignoreErrors: []) //[".*errorcode=.*", "Im cusom Error"]
Ignore Urls
The ignoreUrls option allows you to exclude network requests that meet specific criteria. This options accepts a set of strings and regular expressions to match against the event's network url. Use regular expressions for exact matching as strings remove partial matches.
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
ignoreUrls: []) //[".*\\.il$","https://www.coralogix.com/academy"])
Label Providers
Provide labels based on url or event
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
labels: ["item" : "item_number_5", "itemPrice" : 1000])
CollectIPData
Determines whether the SDK should collect the user's IP address and corresponding geolocation data. Defaults to true.
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
collectIPData: true)
Sample Rate
Number between 0-100 as a percentage of SDK sessions should be initialized.
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
sessionSampleRate: 100)
Excluding Instrumentations from Session Sampling
Opt specific event categories out of the sessionSampleRate gate so they always export, even from sessions that are otherwise sampled out. Useful when you want a low session sample rate for general telemetry but still need every log and error captured.
In the example below, only 10% of sessions are sampled in for the full event stream; the remaining 90% of sessions still export .logs and .errors, but every other category is dropped.
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
sessionSampleRate: 10,
excludeFromSampling: [.logs, .errors])
Accepted ExcludableInstrumentation cases:
.errors.logs.network.userInteractions.mobileVitals.customSpan.customMeasurement
Back-compat: The default is an empty set — sessionSampleRate gates the entire SDK exactly as before. Add categories to excludeFromSampling to let them bypass the gate.
Parity note: the Coralogix Browser SDK exposes the same option with matching semantics.
Telling excluded events apart in beforeSend
Every event carries session_context.isSessionSampledIn (read-only). false means the event reached export only because its category is listed in excludeFromSampling — the session itself was sampled out. Use it in beforeSend to apply your own filtering on top of the exclude list, e.g. keep only crashes and ANRs from sampled-out sessions:
beforeSend: { cxRum in
let session = cxRum["session_context"] as? [String: Any]
let sampledIn = session?["isSessionSampledIn"] as? Bool ?? true
let severity = (cxRum["event_context"] as? [String: Any])?["severity"] as? Int
// Session sampled out: forward only error-severity events, drop the rest.
if !sampledIn && severity != 5 {
return nil
}
return cxRum
}
Trace Exporter
Forward span data to your own collector or backend by configuring a trace exporter callback. The callback receives each batch on its way out, in OTLP-compatible shape, and spans continue to flow to Coralogix when it is set.
Two things to know about where it sits in the pipeline: the batch has already been filtered, sampled and de-duplicated, so this is not a stream of every span produced; and it runs before beforeSend, so anything beforeSend would redact or drop is still present here. Sanitize attributes yourself before forwarding.
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
tracesExporter: { data in
// data.tracesData.resourceSpans[].scopeSpans[].spans[]
// data.jsonString — JSON-encoded OTLP payload, nil if encoding fails
if let json = data.jsonString {
// Hand the work to your own queue: this callback runs on the
// export path, so blocking here delays the batches behind it.
DispatchQueue.global(qos: .utility).async {
forwardToCustomCollector(json)
}
}
})