TraceWaterfall

Molecule

A distributed trace as nested rows with offset and duration bars on a time ruler. Collapse and expand, critical-path highlight, error spans (icon and text, not only colour), a detail region for the selected span, and windowing above `virtualizeThreshold` rows. Tree semantics (role tree and treeitem, aria-level, aria-expanded, aria-selected) with aria-activedescendant. Same locals, DOM and classes as kui-react. The server draws the rows of the render-time state and holds the others in a `<template>`; `TraceWaterfall/scripts/trace-waterfall.js` (inlined once, idempotent) moves them in as the list is expanded or scrolled. `renderDetail` takes a function returning escaped text, or `detailPartial` a partial path (React takes a node); `onSelect` and `onCollapsedChange` are the bubbling `kui:trace-select` and `kui:trace-collapsed-change` events; `selectedId` / `collapsedIds` (controlled in React) are the state at render time and make the script only emit them. At most `maxSpans` spans (default 2000) are drawn.

Default, with the critical path and an error span

Preview
8 spans 412 ms
POST /checkout web
auth.verify auth
cart.load cart
SELECT cart_items cart
inventory.reserve inventory
UPDATE stock inventory
error payment.charge payment
error POST gateway/charge payment

payment.charge

Service
payment
Start
+264 ms
Duration
140 ms
Self time
10 ms
Status
error

Attributes

error.type
GatewayTimeout
Code
<%- include('modules/ui/TraceWaterfall', { spans: spans, defaultSelectedId: 'pay' }) %>
<script>
  document.addEventListener('kui:trace-select', (e) => openSpan(e.detail.id));
</script>

Collapsed start, custom detail slot

Preview
8 spans 412 ms
POST /checkout web
auth.verify auth
error payment.charge payment
error POST gateway/charge payment
cart.load ran for 96 ms; 16 ms of it was its own work.
Code
<%- include('modules/ui/TraceWaterfall', {
  spans: spans,
  defaultCollapsedIds: ['cart'],
  renderDetail: (span, info) => span.name + ': ' + info.selfTime + ' ms self',
  // or detailPartial: '/abs/path/to/span-panel.ejs'  (locals: span, info)
}) %>

400 spans (windowed)

Preview
401 spans 18 s
batch.import worker
error step 0 worker
step 1 db
step 2 cache
step 3 worker
step 4 db
step 5 cache
step 6 worker
step 7 db
step 8 cache
step 9 worker
step 10 db
step 11 cache
step 12 worker
step 13 db
step 14 cache
step 15 worker
step 16 db
step 17 cache
step 18 worker
step 19 db
step 20 cache
step 21 worker
Code
<%- include('modules/ui/TraceWaterfall', { spans: manySpans, maxHeight: 320, virtualizeThreshold: 100 }) %>
Source modules/ui/TraceWaterfall.ejs