Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fuser-guides%2Frum%2Fsdk-features%2Ftrace-exporter.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fuser-guides%2Frum%2Fsdk-features%2Ftrace-exporter.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# Trace exporter

## What is trace exporter[​](#what-is-trace-exporter "Direct link to What is trace exporter")

With the Trace Exporter feature, you can take full control of how to handle trace data collected by the Coralogix RUM SDK. By configuring a `tracesExporter` callback, you can intercept trace data, inspect or modify it, and decide if and where to forward it. This supports advanced use cases such as server-side filtering, enrichment, and tail-based sampling, where decisions are made after traces are collected rather than at capture time.

Trace Exporter is supported in the Coralogix RUM Browser SDK and the Coralogix Android SDK (2.11.0 and later).

## Why it matters[​](#why-it-matters "Direct link to Why it matters")

* Control trace volume by filtering or sampling traces before ingestion.
* Enrich trace data with business or environment context in your own backend.
* Implement tail-based sampling based on trace outcomes, such as errors or latency.
* Integrate with existing OpenTelemetry-compatible collectors running in your infrastructure.

## How it works[​](#how-it-works "Direct link to How it works")

When you configure `tracesExporter`, the SDK invokes your callback with trace data in **OTLP/JSON format**, which mirrors the official OpenTelemetry Protobuf schema for traces and is commonly used when OTLP is sent over HTTP.

Behavior differs by platform:

* **Browser SDK** — your callback replaces the default exporter. The SDK stops automatically forwarding traces to Coralogix and your callback becomes the single export pipeline, responsible for forwarding any traces you want to keep.
* **Android SDK** — your callback runs alongside the default exporter. The SDK continues sending traces to Coralogix as usual; your callback receives a copy of each OTel span as a raw OTLP payload, enabling distributed-tracing integrations without a separate OpenTelemetry collector.

## What you need[​](#what-you-need "Direct link to What you need")

* [Coralogix RUM Browser SDK](https://docs-docusaurus.kinsta.page/user-guides/rum/sdk-installation/javascript/npm-browser/.md) or [Android SDK](https://docs-docusaurus.kinsta.page/user-guides/rum/sdk-installation/android/.md) (2.11.0 and later) with tracing enabled
* An endpoint capable of receiving OTLP/JSON trace payloads (for example, your own backend or the Coralogix OTLP ingestion endpoint)

## Configuration[​](#configuration "Direct link to Configuration")

### Browser[​](#browser "Direct link to Browser")

Define the `tracesExporter` callback as a top-level property in `CoralogixRum.init`.

```
CoralogixRum.init({

tracesExporter:(data) => {

  // Forward trace data to your backend or OTLP-compatible endpoint

  }

});
```

### Android[​](#android "Direct link to Android")

Set the `tracesExporter` callback in `CoralogixOptions`. The callback receives a `CoralogixTraceExporterData` object with the raw OTLP span payload alongside the standard RUM export.

```
val options = CoralogixOptions(

    // ...

    tracesExporter = { data ->

        // Forward OTLP span payload to your backend or OTLP-compatible endpoint

    }

)
```

For Android SDK setup, see the [Android SDK installation guide](https://docs-docusaurus.kinsta.page/user-guides/rum/sdk-installation/android/.md).

## Forwarding traces to Coralogix[​](#forwarding-traces-to-coralogix "Direct link to Forwarding traces to Coralogix")

In the Browser SDK, including `tracesExporter` stops automatic trace forwarding. To send traces to Coralogix, manually forward the payload from within the callback. If you forward the entire payload unchanged, all collected traces are sent as-is. You can also add conditional logic to filter, enrich, or reroute specific traces before forwarding.

In the Android SDK, the SDK continues forwarding traces to Coralogix automatically. Use the callback only to deliver the OTLP payload to your own backend or collector.

## Pass-through and selective handling[​](#pass-through-and-selective-handling "Direct link to Pass-through and selective handling")

In the Browser SDK, if you only want to intervene on a subset of traces, use a pass-through approach:

* Forward all trace batches to Coralogix by default
* Apply custom logic for specific traces or batches, such as dropping low-value traces or enriching error traces

This ensures you retain full trace visibility while still applying targeted processing.

## Payload format[​](#payload-format "Direct link to Payload format")

The callback receives a `TraceExporterData` object that follows the OpenTelemetry Collector trace format. At a high level, the payload includes resources, scopes, and spans grouped into batches.

```
{

  "resource_spans": [

    {

      "resource": {

        "attributes": [

          { "key": "service.name", "value": { "string_value": "my-service" } }

        ]

      },

      "scope_spans": [

        {

          "scope": { "name": "rum-sdk" },

          "spans": [

            {

              "trace_id": "7f3a2c1e9b4d4f0a8c7d6e5f4a3b2c1d",

              "span_id": "1a2b3c4d5e6f7081",

              "name": "fetch-data",

              "start_time_unix_nano": "1665753217736722000",

              "end_time_unix_nano": "1665753217737156416"

            }

          ]

        }

      ]

    }

  ]

}
```

## User responsibility and limitations[​](#user-responsibility-and-limitations "Direct link to User responsibility and limitations")

When using `tracesExporter`, you assume responsibility for:

* Forwarding traces to your own destination (and, in the Browser SDK, to Coralogix)
* Error handling and retries for failed exports
* Performance considerations, ensuring the callback does not block the main thread
* Data loss prevention, as the SDK does not retry exports on your behalf

Tip

In the Browser SDK, defining `tracesExporter` fully replaces the SDK's default trace exporter. The SDK does not continue exporting traces automatically in parallel. In the Android SDK, the callback runs alongside the default exporter, so traces continue to reach Coralogix automatically.
