Fix traces unmarshal error on fractional mem_delta - #21
Merged
Merged
Conversation
The Scout API reports a trace's mem_delta as a float in megabytes (e.g. 0.0, 2.9296875), but TraceEntry and TraceDetail declared it as int64, so `scout traces list` and `scout traces show` failed with: json: cannot unmarshal number 2.9296875 into Go struct field TraceEntry.traces.mem_delta of type int64 Decode mem_delta as float64 and format it as MB (matching the Scout UI) via a new output.FormatMB helper, instead of treating it as a byte count. Adds regression tests using live-shaped payloads (float, 0.0, null and integer mem_delta values). Closes #19 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BK3fzED9ksTWsvoPfsEwpS
The API reports total_call_time in milliseconds (the Scout UI renders it with an "ms" suffix and Request#total_call_time_in_seconds converts from ms). `scout traces list` formatted it as seconds, so an 83-second request displayed as "83483.9s". Use FormatMs for the Duration column and drop the extra *1000 in the legacy-trace fallback of the span tree header. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BK3fzED9ksTWsvoPfsEwpS
4 tasks
Replace trace ids, URIs and endpoint names copied from live output with generic placeholders. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BK3fzED9ksTWsvoPfsEwpS
jrothrock
approved these changes
Sep 10, 2026
This was referenced Sep 10, 2026
Closed
Merged
This was referenced Sep 14, 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.
Closes #19
Summary
scout traces listandscout traces showfailed for any app whose traces carry a memory delta:The API reports
mem_deltaas a float in megabytes (0.0,2.9296875,null, …), matching therequests.mem_deltafloat column and the Scout UI's "N MB" rendering. The CLI declared it asint64bytes, so decoding failed on the first fractional value and, when it didn't fail,FormatByteswould have shown "2 B" for a 2 MB increase.Changes
TraceEntry.MemDeltaandTraceDetail.MemDeltaare nowfloat64(MB).output.FormatMBhelper renders2.9 MB,12 MB,1.5 GB; used by the traces table and the span-tree footer (Memory: +2.9 MB).FormatSecondsontotal_call_time, but the API reports it in milliseconds (the UI renders it with anmssuffix;Request#total_call_time_in_secondsconverts from ms). An 83-second request displayed as83483.9s; it now shows83.5s. The legacy-trace fallback in the span-tree header had the same*1000error.0.0,null, and integermem_deltafor both list and detail;FormatMBtable test; span-tree footer and legacy header tests.## Pending→### Fixedentries.Before / after (illustrative)
Before:
After:
Note for the reporter: the second error in the issue (
invalid character 'N' looking for beginning of valuewhen passing a raw endpoint name) was addressed in 0.4.0, which now surfaces the HTTP status and body instead. The Base64 endpoint id from the URL is the correct input.Test plan
go test -race ./...golangci-lint run ./...scout traces list --endpoint <id> --app <id> --from 6d(table,--json,--toon)scout traces show <trace-id> --app <id>🤖 Generated with Claude Code
https://claude.ai/code/session_01BK3fzED9ksTWsvoPfsEwpS