Skip to content

Render nested perf spans in traces#1073

Merged
pfleidi merged 8 commits intomainfrom
feat/recursive-perf-spans
Apr 30, 2026
Merged

Render nested perf spans in traces#1073
pfleidi merged 8 commits intomainfrom
feat/recursive-perf-spans

Conversation

@pfleidi
Copy link
Copy Markdown
Contributor

@pfleidi pfleidi commented Apr 29, 2026

https://entire.io/gh/entireio/cli/trails/260

What

Improves perf trace output so nested named spans remain readable instead of being rendered as anonymous numeric substeps.

How

  • Recursively serializes perf span children into dotted steps.* keys.
  • Preserves StartLoop() iteration keys like steps.process_sessions.0_ms.
  • Rebuilds nested step trees in entire trace and renders arbitrary-depth substeps.
  • Keeps duplicate sibling names disambiguated with the existing ~N suffix behavior.

Verification

  • mise run build
  • mise run check

Note

Medium Risk
Changes the serialized shape of perf trace log keys and the CLI reconstruction/rendering logic, which could break trace parsing/consumers or subtly reorder/mis-group steps if assumptions differ.

Overview
Improves perf tracing to preserve arbitrary-depth nested spans instead of collapsing them into anonymous numeric substeps.

On the logging side (perf/span.go), span serialization is now recursive, emitting dotted steps.<parent>.<child>_ms (and _err) keys for nested named spans while preserving loop iteration numbering via steps.<loop>.0_ms, steps.<loop>.1_ms, etc., and keeping the existing ~N sibling de-duplication behavior.

On the CLI side (cmd/entire/cli/trace.go), entire trace now rebuilds a nested step tree from dotted keys, sorts numeric children numerically, and renders a tree table for any depth with correct column alignment (using lipgloss.Width). Tests add coverage for nested named spans, nested error flags, duplicate nested sibling names, and deep rendering.

Reviewed by Cursor Bugbot for commit 9f713da. Configure here.

pfleidi added 5 commits April 28, 2026 15:54
Entire-Checkpoint: d1403971e2a9
Entire-Checkpoint: 6fcc37f3f65e
Entire-Checkpoint: 48f7bfda75ed
Entire-Checkpoint: b586effcbc5e
- Mark loop iterations with an explicit isLoopIter flag on Span and
  serialize them via that flag rather than parent/child name equality.
  Same-name nested spans are no longer mistaken for loop iterations.
- Inline childStepPath into appendChildStepAttrs and drop the stale
  attrs capacity hint that no longer matched the recursive walk.
- Collapse the trace renderer width pass and render pass into one walk
  that builds a flat traceRenderRow list, removing duplicate connector
  and label computation.
- Use lipgloss.Width in the renderer for visible-width math, matching
  auth.go and activity_render.go, and drop the local displayWidth
  wrapper.
- Rewrite traceStepParent as a clearer for { ... } loop.

Entire-Checkpoint: cf260362883f
Copilot AI review requested due to automatic review settings April 29, 2026 00:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves performance trace serialization and rendering so nested spans remain named and readable (instead of collapsing into numeric substeps), while preserving numeric loop-iteration step keys.

Changes:

  • Recursively serializes child spans into dotted steps.* attribute keys, preserving loop iteration numbering and sibling-name disambiguation (~N).
  • Rebuilds a nested step tree in entire trace parsing to support arbitrary-depth substeps.
  • Updates trace rendering to display nested substeps with proper alignment for box-drawing connectors, plus adds/extends unit tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
perf/span.go Serializes nested spans recursively into dotted steps.* keys; adds loop-iteration marker to preserve numeric iteration keys.
perf/span_test.go Adds coverage for nested-span serialization, loop iteration keys, sibling deduplication, and nested error flags.
cmd/entire/cli/trace.go Parses dotted steps.* keys into an arbitrary-depth tree and renders nested steps with width-aware alignment.
cmd/entire/cli/trace_test.go Adds/extends tests for nested named spans in parsing and rendering.

Comment thread perf/span.go Outdated
Entire-Checkpoint: ad605be45532
@pfleidi
Copy link
Copy Markdown
Contributor Author

pfleidi commented Apr 29, 2026

Bugbot run

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 9f713da. Configure here.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@pfleidi pfleidi marked this pull request as ready for review April 29, 2026 00:51
@pfleidi pfleidi requested a review from a team as a code owner April 29, 2026 00:51
gtrrz-victor
gtrrz-victor previously approved these changes Apr 30, 2026
Match the rest of the repo's lipgloss import path. Avoids
dragging github.com/charmbracelet/lipgloss back into go.mod
and unblocks lint + tests on CI.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pfleidi pfleidi merged commit 4dd3ff8 into main Apr 30, 2026
9 checks passed
@pfleidi pfleidi deleted the feat/recursive-perf-spans branch April 30, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants