log2trace-ui Guide
API Docs GitHub
Views & Styling

Visual Setups, Views & Theming

Adapt <trace-visualizer> to any embedding context — from a dense 280 px PR-check widget or obsidian incident-command console to a spacious 4-view observability workspace — using declarative <trace-view> children, geometry attributes, and --l2t-* CSS design tokens.

1Visual Setup Archetypes

Switch between four production-ready visual & data-complexity configurations below. Notice how row density, theme tokens, span-kind palettes, tab composition, and dataset shape work together — and copy the exact markup for any setup.

43 spans · 9 services · 6 tabs
HTML — Full 6-View Observability Suite

2Waterfall Geometry, Sizing & Keyboard Navigation

Tune row density with span-height and span-padding, adjust the label column with gutter-width, size the inspector with detail-panel-width, or enable plain-wheel zooming with wheel-zoom.

HTML — Waterfall Layout & Sizing Attributes

Waterfall Keyboard & Pointer Controls

InputAction
↑ / ↓Select previous or next visible span row
Shift + ← / →Collapse or expand the selected span's subtree
← / →Pan timeline camera left or right
+ / - / 0 (Home)Zoom in, zoom out, or reset zoom to 100%
PageUp / PageDownScroll vertically by one viewport page
Enter / SpaceMove keyboard focus into the open detail panel for the selected span
EscapeReturn focus from detail panel/filter to timeline, or clear selection and close detail panel
Ctrl/⌘ + FFocus the first filter control when a filter bar is configured
Wheel / Ctrl+Wheel / DragWheel scrolls rows; Ctrl/⌘+Wheel (or pinch) zooms at cursor; drag pans; double-click resets zoom

3Flame Graph & Service Dependency Map

Flame Graph (type="flame") folds repeated call paths — such as the 5 vector-shard probes and 3 Postgres chunk fetches in our AI Hybrid RAG trace — into cumulative hotspot boxes. Service Map (type="service") renders a directed topology of all 9 microservices and their inferred external peers (Qdrant, Elasticsearch, Redis, Postgres, Kafka) with live latency and error rates.

Try synchronized exploration: Double-click any Flame box (or press F) to zoom that call path to full width (Escape steps out). Switch to Service Map to pan/zoom the 2D DAG and click a service node or edge — selection stays synchronized across tabs.
HTML — Flame Graph & Service Topology Tabs
<trace-visualizer data-url="./data/ai-search-trace.json" show-legend>
  <trace-view type="flame" active></trace-view>
  <trace-view type="service"></trace-view>
  <trace-view type="waterfall"></trace-view>
</trace-visualizer>

4Sequence Diagram & Per-View Options

<trace-view type="sequence"> draws causal participant lifelines, synchronous request/return arrows, asynchronous Kafka pub/sub hops, and automatic loop folding. Below, the AI Hybrid RAG trace runs 5 consecutive VectorSearch/QueryShard calls (folded into loop ×5 when fold="3") and fails over after a 429 rate-limit error.

HTML — Per-View Attributes on <trace-view type="sequence">

5Trace Statistics & Per-View Options

<trace-view type="stats"> aggregates spans by service-operation, service, operation, kind, or switches to flat none (Spans) mode — ranking N+1 hotspots, error rates, exclusive self-time, recursion-safe totals, and latency percentiles (Min, Avg, P50, P95, Max). Click any group chevron (or press →) to inspect individual member spans inline.

HTML — Per-View Attributes on <trace-view type="stats">

6Service Lanes & Concurrency

<trace-view type="lanes"> draws one swimlane per service on a shared time axis, so you can see who was busy when and how much ran in parallel. Each lane is split into levels: concurrent spans are packed into as few rows as possible, and a child always sits below its same-service parent. Services' external dependencies appear as ghost peer lanes (italic name, hatched or outlined bars): calls seen from the caller to an uninstrumented database, cache, broker, or host. When thousands of spans fall inside a few pixels, they collapse into merged hatched bars whose tooltip shows the count; zoom in to split them again.

A lane taller than max-rows is capped with a +N rows overflow row (click it to show every level). A collapsed lane becomes a one-row in-flight concurrency area chart with error ticks; with a filter active it counts only matching requests. The gutter reports each lane's spans · busy % · peak concurrency · errors, and hovering an empty stretch of a lane (between spans, or before its first and after its last) shows its idle time. Selecting a span fades everything outside its request's causal tree.

Try it on the worker pool: 40 image tasks run on an 8-slot image-worker pool, so that lane stays pinned at 8 concurrent spans (saturation), preceded by a ~140 ms idle gap while job-scheduler waits on an uninstrumented feature-flag call. Hover the empty space at the start of the image-worker lane to read the idle time, double-click it to zoom to it, collapse image-worker to see its concurrency curve, then switch on Errors Only to count only the 3 failing tasks.
Dataset
HTML — Per-View Attributes on <trace-view type="lanes">

Lanes Keyboard & Pointer Controls

InputAction
← / →Select the previous or next span on the same track (level row)
↑ / ↓Select the parent span, or the first child
Enter / SpaceCollapse or expand the lane of the selected span
E / GExpand all lanes / collapse all lanes (also the Expand all and Collapse all toolbar buttons)
+ / - / 0 (Home)Zoom in, zoom out, or reset zoom to 100%
FZoom to the selected span
PageUp / PageDownScroll the lanes vertically by one viewport page
EscapeClear the selection and close the detail panel
ClickSelect a span or merged run (Ctrl/⌘/Shift+click adds to the selection); click a lane header to collapse or expand the lane; click +N rows to show all levels
Double-clickZoom to a span, a merged run, or an idle gap
Ctrl/⌘+Wheel / DragCtrl/⌘+wheel (or pinch) zooms at the cursor; drag pans the timeline; hover an empty gap in a lane to see its idle time

Lanes vs. Waterfall vs. Flame Graph

ViewBest for
LanesConcurrency and saturation per service: worker pools, fan-out, idle gaps, retry storms, and who was busy at a given moment. Handles tens of thousands of spans through merging.
WaterfallOne request's causal tree in call order: exact parent/child nesting, per-span timing, and log events.
Flame GraphWhere the cumulative time went: identical call paths folded into hotspot boxes, with no time axis.

7Themes, Span-Kind Colors & CSS Tokens

By default, <trace-visualizer> follows prefers-color-scheme. Pin it with theme="light" or theme="dark", override span-kind colors via kind-colors, or customize any surface, grid, border, accent, or font using CSS custom properties (--l2t-color-* and --l2t-font-*).

CSS + HTML — Custom Tokens & kind-colors

CSS Custom Property Reference

Custom PropertyLight DefaultDark DefaultUsage
--l2t-color-background#ffffff#1b1d23Primary stage & viewport background
--l2t-color-surface#f6f7f9#23262eToolbar, tabs, filter bar, and detail panel surface
--l2t-color-border / --l2t-color-grid#dddddd / #ececec#3a3e49 / #2c3039Hairline dividers and timeline ruler gridlines
--l2t-color-text / --l2t-color-textMuted#333333 / #666666#e4e6eb / #9aa0acPrimary labels and secondary timestamps/metadata
--l2t-color-accent#007bff#4da3ffActive tab indicator, focus ring, and primary interactive controls
--l2t-color-error#c62828#ff6b6bFailed span markers, error badges, and error status messages
--l2t-color-kindServer … kindConsumerSet automatically or via kind-colorskindUnspecified, kindInternal, kindServer, kindClient, kindProducer, kindConsumer
--l2t-font-sans / --l2t-font-monoSystem UI / MonospaceUI chrome font stack and numeric/code font stack

8Extending with registerView()

Register custom views implementing TraceView via registerView({ id, label, capabilities, create }) and declare them alongside built-in views as <trace-view type="your-id">. Below is a live Slowest Spans leaderboard over the 43-span AI Hybrid RAG trace sharing filter and selection state with Waterfall and Flame Graph.

JavaScript — Registering a Custom Synchronized View
import { registerView, formatDuration, spanKindName } from 'log2trace-ui';

// Register before <trace-visualizer> upgrades (or set viz.view = 'hot-spans'
// after re-inserting its <trace-view> carrier if the element was already parsed).
registerView({
  id: 'hot-spans',
  label: 'Slowest Spans',
  capabilities: { legend: false },
  create() {
    let root = null;
    let ctx = null;

    function render() {
      if (!root || !ctx) return;
      const { data, selection, matched } = ctx.store.state;
      const rows = [...data.index.ordered]
        .filter((s) => matched === null || matched.has(s.spanId))
        .sort((a, b) => b.durationMs - a.durationMs);
      // Render rows and write selection back via:
      // ctx.store.setSelection([span.spanId], { origin: ctx.origin, primary: span.spanId });
    }

    return {
      mount(surface, viewCtx) {
        ctx = viewCtx;
        root = document.createElement('div');
        surface.appendChild(root);
        render();
      },
      update() { render(); },
      optionsChanged() {},
      themeChanged() { render(); },
      commands: () => [],
      getState: () => null,
      setState() {},
      unmount() { root?.remove(); root = null; ctx = null; },
    };
  },
});