Skip to content

Add in-memory trace analysis commands#13

Merged
V3RON merged 3 commits intomasterfrom
feat/trace-analysis
May 6, 2026
Merged

Add in-memory trace analysis commands#13
V3RON merged 3 commits intomasterfrom
feat/trace-analysis

Conversation

@V3RON
Copy link
Copy Markdown
Contributor

@V3RON V3RON commented May 6, 2026

Summary

  • add in-memory trace sessions so trace stop analyzes captured events and agents can inspect them without reading raw trace files
  • add trace status|list|summary|tracks|entries|entry commands with compact, filterable output for user timings and custom DevTools tracks
  • keep raw trace recording opt-in and backward-compatible by preserving trace start / trace stop [--file PATH] while routing parsing into a separate src/trace/ module

Backward Compatibility

  • Existing trace capture remains explicit: tracing still starts only when trace start is invoked.
  • trace stop --file PATH still exports raw traceEvents JSON; it now also creates an in-memory analyzed session and returns a richer summary.
  • Existing daemon lifecycle, target/session flow, and newline-delimited IPC remain unchanged.
  • The CLI surface only adds new trace subcommands and does not change defaults for other command families.

Risks

  • User timing parsing currently relies on a lightweight normalization layer rather than a full DevTools handler port, so uncommon trace event shapes may still be missed.
  • Track grouping and console timestamp range reconstruction are derived from recorded trace data; unusual producer behavior could land entries on the default track.
  • In-memory session retention is bounded, which keeps token and memory usage under control but means older trace sessions are evicted after the cap is reached.

Manual testing

  • Setup: run the daemon, select a Chrome target, and load a page that emits performance.measure, performance.mark, and optional custom DevTools track metadata.
  • Start capture: run agent-cdp trace start, exercise the page, then run agent-cdp trace stop --file /tmp/trace.json.
  • Verify summary: run agent-cdp trace summary and confirm it reports a new session with entry counts and top tracks.
  • Verify navigation: run agent-cdp trace tracks, then agent-cdp trace entries --track Timings, and finally agent-cdp trace entry --id <ENTRY_ID> to confirm drill-down output stays compact and filterable.
  • Verify compatibility: open /tmp/trace.json and confirm raw traceEvents were still exported.

Validation

  • pnpm format
  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build

Closes #12

@V3RON V3RON merged commit b8a9dfb into master May 6, 2026
4 checks passed
@V3RON V3RON deleted the feat/trace-analysis branch May 6, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add in-memory trace analysis for user timings and custom DevTools tracks

1 participant