Skip to main content

Traces module · loader API

OTLP trace loaders

Read binary OTLP protobuf, protobuf-JSON, or JSON Lines into the shared five-table Arrow projection used across the trace module.

What it returns

Make trace sources comparable.

Both OTLP input encodings resolve to the same relational Arrow model, so applications can analyze or transform traces without branching on the wire representation.

Resources

Service and resource attributes

Scopes

Instrumentation scope metadata

Spans

Span timing, status, and relationships

Events

Events and links as related tables

Detailed guide

OTLP trace loader reference

The sections below document binary and JSON loaders, parser access, result tables, options, and batch behavior.

OtlpTraceLoader reads binary OTLP protobuf. OtlpTraceJsonLoader reads OTLP protobuf-JSON and JSON Lines. Both return the same five-table OtlpTrace Arrow projection.

Usage​

import {load} from '@loaders.gl/core';
import {OtlpTraceJsonLoader, OtlpTraceLoader} from '@loaders.gl/traces/otlp';

const protobufTrace = await load('traces.otlp', OtlpTraceLoader);
const jsonTrace = await load('traces.otlp.json', OtlpTraceJsonLoader);

console.log(protobufTrace.resources);
console.log(protobufTrace.scopes);
console.log(protobufTrace.spans);
console.log(protobufTrace.events);
console.log(protobufTrace.links);

The package-root exports are metadata-only and support asynchronous core APIs through preload(). For direct access to parser-bearing loaders, use:

import {OtlpTraceLoaderWithParser} from '@loaders.gl/traces/otlp';
import {OtlpTraceJsonLoaderWithParser} from '@loaders.gl/traces/otlp';

Result​

type OtlpTrace = {
resources: OtlpResourceArrowTable;
scopes: OtlpScopeArrowTable;
spans: OtlpSpanArrowTable;
events: OtlpEventArrowTable;
links: OtlpLinkArrowTable;
};

Options​

OptionTypeDefaultDescription
otlpTrace.batchSizenumber4096Maximum rows in each tagged Arrow record batch.

Invalid, non-finite, or non-positive batch sizes use the default.

Batched Parsing​

import {parseInBatches} from '@loaders.gl/core';
import {OtlpTraceLoader} from '@loaders.gl/traces/otlp';

const batches = await parseInBatches(byteChunks, OtlpTraceLoader, {
otlpTrace: {batchSize: 1024}
});

for await (const batch of batches) {
consume(batch.table, batch.data);
}
type OtlpTraceBatch = {
table: 'resources' | 'scopes' | 'spans' | 'events' | 'links';
data: arrow.RecordBatch;
};

The binary loader emits after complete top-level ResourceSpans messages arrive. The JSON loader streams newline-delimited documents and falls back to whole-document parsing for pretty JSON.

Detection​

The protobuf loader recognizes .otlp and .otlp-trace. The JSON loader recognizes .otlp.json and .otlp.jsonl. Generic protobuf and JSON MIME types are supported when the loader is selected explicitly; those MIME types alone are not unique enough to identify OTLP among all formats.

Errors​

Malformed protobuf, truncated final fields, invalid JSON, invalid hexadecimal identifiers, and trace or span identifiers with the wrong fixed width throw parsing errors.