LEVEL 3 · ENGINEER

Agent Trace Debugger

A before-and-after regression report that explains overlap, own time and failed-token spending. Export one Span JSON object per line from your instrumentation and retain trace.json beside trace.html in CI.

4 stages~8 hoursTypeScriptcore
Read a JSONL traceValidate parent relationshipsSeparate work time from waiting timeRender an inspectable timeline
YOU END UP WITH

A before-and-after regression report that explains overlap, own time and failed-token spending.

USEFUL FOR
  • Export one Span JSON object per line from your instrumentation and retain trace.json beside trace.html in CI.
LEARN FIRST
  • Node 22.18+ and Python 3 for the grader
  • TypeScript objects, arrays, Map, sorting and interval arithmetic.
PROJECT OUTLINE

Agent Trace Debugger in 4 stages

A before-and-after regression report that explains overlap, own time and failed-token spending.

  1. Read a JSONL trace

    Parse one JSON object per nonempty line. Require stable ids, names, finite start and end times, nonnegative token counts and an explicit ok or error state. A malformed line stops processing with its line number. Silently dropping bad spans would distort timing and cost conclusions. Times are relative milliseconds, not wall-clock timestamps.

    starter · ~2 hours · TypeScript

    parseTrace
  2. Validate parent relationships

    A child span must reference an existing parent and fit inside the parent interval. Check every ancestor chain for cycles and reject duplicate ids. Multiple roots are allowed because a trace can contain overlapping independent runs. Validation happens before aggregation so corrupted graphs cannot produce convincing charts.

    core · ~2 hours · TypeScript

    validateTree
  3. Separate work time from waiting time

    Inclusive duration is end minus start. Exclusive duration subtracts the union of immediate child intervals, not their sum, because parallel children overlap. Root interval union provides wall time across runs. Tokens are local per span and summed once. The slowest result names the span with greatest exclusive duration, avoiding a root that is mostly waiting on children.

    core · ~2 hours · TypeScript

    unionDurationanalyze
  4. Render an inspectable timeline

    Generate a standalone HTML timeline with one row per span, scaled bars and error coloring. Escape span names before inserting them into markup. Include own time, total time, wall time, tokens and error count. Empty traces still produce a readable artifact. The output is a local static report and does not load third-party scripts.

    core · ~2 hours · TypeScript

    render

All projects · Course catalog · Source on GitHub