log2trace-ui Guide
API Docs GitHub
Interactive Documentation

Getting Started & Data Transformation

log2trace-ui is a zero-dependency Web Component that renders OpenTelemetry traces and transforms arbitrary structured JSON logs into interactive waterfalls, flame graphs, service maps, sequence diagrams, service lanes, and trace statistics — entirely client-side.

<script type="module" src="https://unpkg.com/log2trace-ui/dist/log2trace.min.js"></script>
<trace-visualizer data-url="./data/edge-auth-trace.json"></trace-visualizer>
Four declarative custom elements: Importing the bundle registers <trace-visualizer> alongside three lightweight configuration carriers: <trace-view> (views & per-view options), <trace-filter> (local & external filter inputs), and <span-kind-rule> (log-to-span kind classification).

1Native OpenTelemetry Traces

Point data-url at any standard OTLP JSON endpoint ({ resourceSpans: [...] }) or assign it directly to .traceData. Switch between sample traces below — from a compact 14-span edge auth request to a 43-span parallel AI RAG pipeline with 429 failover and a 2.8 s incident retry storm.

Delivery
Loading…
HTML — Declarative OTel Trace

2Transforming Raw Logs into Traces

Pass raw JSON logs in your native schema (shown below with a 3-trace Card Settlement & Fraud Pipeline dataset in ./data/fintech-logs.json). Dot-paths such as trace.id and service.name map log fields to OTel spans, while every underlying log entry is preserved as a span event in the detail inspector.

API Style
Loading…

Transform Field Mapping Reference

HTML Attribute JS Config Key Required Purpose
trace-id-field traceIdField Yes Dot-path to the correlation / trace ID that clusters logs into traces (e.g. trace.id).
span-name-field spanNameField Yes Dot-path used as the operation name displayed on the span bar (e.g. operation).
service-name-field serviceNameField Yes Dot-path identifying the service / resource (service.name) of the span.
timestamp-field timestampField Yes Dot-path to an ISO 8601 timestamp string or epoch-millisecond number.
span-group-fields spanGroupFields Optional Comma-separated dot-paths (or string[]) grouping multiple logs into one span; start/end derive from min/max timestamps. When omitted, each log becomes its own span.
end-time-field endTimeField Optional Explicit span end timestamp dot-path when a single log carries both start and end times.
parent-span-id-field parentSpanIdField Optional Direct parent span ID field when logs already record caller span IDs.
parent-span-lookup-fields parentSpanLookupFields Optional Positional lookup against spanGroupFields (e.g. caller matches parent service.name) to reconstruct call hierarchies without explicit parent span IDs.
span-id-field spanIdField Optional Unique log record ID used in one-log-per-span mode.
status-code-field statusCodeField Optional Error indicator field; non-zero or truthy values mark the resulting span with OTel Error status (code 2).
default-span-kind defaultSpanKind Optional Fallback SpanKind when no <span-kind-rule> matches (Unspecified, Internal, Server, Client, Producer, Consumer).

3Span-Kind Classification Rules

<span-kind-rule> children inspect raw log fields during transformation and assign OpenTelemetry SpanKind values, driving bar colors and RPC semantics across all six views. Toggle the rules below on the Card Settlement log dataset to watch spans reclassify in real time.

HTML — Declarative <span-kind-rule> Children

4Headless Core Pipeline (log2trace-ui/core)

Run log transformation, typed-array span indexing, or filter compilation inside a Web Worker, Node.js backend, or CLI without any DOM dependency by importing from log2trace-ui/core.

Click Run to inspect output
import { transformLogs, buildSpanIndex } from 'log2trace-ui/core';

// 1. Convert structured JSON logs into standard OTLP TraceData
const traceData = transformLogs(fintechLogs, {
  traceIdField: 'trace.id',
  spanGroupFields: ['service.name', 'operation'],
  spanNameField: 'operation',
  serviceNameField: 'service.name',
  timestampField: 'ts',
  statusCodeField: 'code',
  parentSpanLookupFields: ['caller'],
});

// 2. Build the columnar typed-array SpanIndex for O(n) filtering & projection
const index = buildSpanIndex(traceData);
console.log({ spans: index.size, roots: index.roots.length, services: index.table.services });