feat(formatters): display span duration in span tree#219
Merged
Conversation
Add per-span duration display to the span tree output. Durations are computed from the API-provided duration field when available, falling back to timestamp arithmetic (end_timestamp or timestamp minus start_timestamp). Format: `op — description (duration)` where duration is shown as 245ms, 1.24s, or 2m 15s depending on magnitude. Also extends TraceSpan type with end_timestamp and duration fields.
Contributor
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Cli
Other
Bug Fixes 🐛Upgrade
Documentation 📚
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 3923 uncovered lines. Files with missing lines (63)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 67.27% 67.31% +0.04%
==========================================
Files 98 98 —
Lines 11986 12002 +16
Branches 0 0 —
==========================================
+ Hits 8063 8079 +16
- Misses 3923 3923 —
- Partials 0 0 —Generated by Codecov Action |
When ms % 60000 >= 59500, rounding seconds produced invalid output like "1m 60s" instead of "2m 0s". Fixed by rounding total seconds first, then splitting into minutes and seconds.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Replace hand-rolled formatSpanDuration with battle-tested pretty-ms library. This handles all edge cases around rounding at tier boundaries (e.g., 999.5ms -> 1s, 59995ms -> 1m) correctly.
This was referenced Feb 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds per-span duration to the span tree output in
issue viewandevent viewcommands. Durations are computed from the API-provideddurationfield when available, falling back to timestamp arithmetic.Changes
computeSpanDurationMs()to extract duration from span dataformatSpanDuration()for human-readable duration formatting (245ms, 1.24s, 2m 15s)formatSpanSimple()to append duration after descriptionTraceSpantype withend_timestampanddurationfieldsExample output:
Test Plan
bun test test/lib/formatters/span-tree.test.ts- all 20 tests passsentry issue viewandsentry event view