-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Description:
To visualize "where" code is executing in the proposed TUI (ferret watch), we need to know which thread and process owns each span. Currently, SpanModel only captures timing and hierarchy data. Without this, the live monitor cannot group active spans by thread (e.g., "Thread-1 is executing fetch_db", "MainProcess is executing setup") or distinguish between multiple worker processes running in parallel.
Proposed Solution:
- Schema Update: Add
thread_id,thread_name, andprocess_idfields to theSpanModel. - Capture Logic: During
Spaninitialization in the Profiler, automatically capture these values using Python's standardosandthreadinglibraries.
Tasks:
- Update Model (
ferret/models.py):- Add fields to
SpanModel:process_id: intthread_id: intthread_name: str(Optional, but highly recommended for TUI readability)
- Add fields to
- Update Core (
ferret/core.py):- In
Span.__init__, capture the context:import os import threading # ... inside __init__ self.model.process_id = os.getpid() self.model.thread_id = threading.get_ident() self.model.thread_name = threading.current_thread().name
- In
- TUI Integration Prep:
- Ensure these fields are indexed or easily accessible so the future
ferret watchapp can group the "Live Stack" byprocess_id -> thread_id.
- Ensure these fields are indexed or easily accessible so the future
Acceptance Criteria:
- Inspecting the
ferret.db(viaferret analyzeor raw check) shows that every span now contains valid PID and Thread ID information. - Spans generated from
asynciotasks correctly reflect the thread running the event loop (usually MainThread). - Spans generated from
concurrent.futures.ThreadPoolExecutorshow distinctthread_ids.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels