-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Description:
The current hierarchical tree visualization in the CLI (ferret analyze --tree) is useful for quick checks, but it becomes unreadable for deep call stacks or complex async traces. Text-based trees cannot effectively visualize time-line distribution or "icicle" views, which are standard for performance engineering.
To make Ferret a viable tool for deep performance debugging, we need to export data in a format compatible with standard visualization tools.
Proposed Solution:
Implement a new export command that generates a JSON file compatible with Speedscope, a popular web-based flame graph viewer. Speedscope supports an "Evented Profile" format (using Open/Close frame events) which maps perfectly to our Start/End span model.
Tasks:
- CLI Command (
ferret/cli.py):- Add a new command
ferret export. - Arguments:
db_path: Path to the database.--run-id: Specific run to export (default to latest).--format: Output format (default tospeedscope).--output/-o: Destination file path (e.g.,ferret_trace.json).
- Add a new command
- Transformer Logic (
ferret/export.py):- Create a new module
ferret.export. - Implement a transformer that reads
SpanModelobjects fromBeaverDBand converts them into the Speedscope File Format Schema. - Tip: Use the "Evented Profile" format. Iterate through spans and emit an
OPEN_FRAMEevent atstart_timeand aCLOSE_FRAMEevent atend_time(calculated viastart_time + duration).
- Create a new module
- Refinement:
- Ensure the time units match Speedscope requirements (microseconds or seconds).
- Map
span.nameto the frame name. - Map
span.tagsto frame args (if supported) or append interesting tags to the frame name for visibility.
Acceptance Criteria:
- Running
ferret export --output trace.jsongenerates a valid JSON file. - Uploading
trace.jsonto speedscope.app successfully renders a generic Flame Graph and a Time Order view. - The visualization accurately reflects the nesting and duration of the recorded spans.