stormlog.phases
Structured phase telemetry helpers for trackers and analysis.
- class stormlog.phases.PhaseAttribution(phase_resolution, phase_source=None, phase_path=None, phase_paths=<factory>, scope_id=None, thread_id=None, thread_name=None, phase_summary=None)[source]
Bases:
objectResolved workload phase attribution for an anomaly or report item.
- Parameters:
phase_resolution (str)
phase_source (str | None)
phase_path (str | None)
phase_paths (list[str])
scope_id (str | None)
thread_id (int | None)
thread_name (str | None)
phase_summary (PhaseSummary | None)
- phase_resolution: str
- phase_source: str | None = None
- phase_path: str | None = None
- phase_paths: list[str]
- scope_id: str | None = None
- thread_id: int | None = None
- thread_name: str | None = None
- phase_summary: PhaseSummary | None = None
- class stormlog.phases.PhaseSummary(phase_path, source)[source]
Bases:
objectOptional presentation-oriented phase winner when canonical attribution stays ambiguous.
- Parameters:
phase_path (str)
source (str)
- phase_path: str
- source: str
- stormlog.phases.attribute_active_spans(spans, *, strategy='deepest_per_thread', origin_thread_id=None, origin_phase_scope_id=None)[source]
Collapse active spans into a unique or ambiguity-preserving attribution.
- Parameters:
spans (Sequence['PhaseSpan'])
strategy (str)
origin_thread_id (int | None)
origin_phase_scope_id (str | None)
- Return type:
PhaseAttribution | None
- class stormlog.phases.PhaseBoundary(event_type, context, metadata, scope_id, path)[source]
Bases:
objectStructured boundary payload emitted into tracker telemetry events.
- Parameters:
event_type (str)
context (str)
metadata (dict[str, Any])
scope_id (str)
path (tuple[str, ...])
- event_type: str
- context: str
- metadata: dict[str, Any]
- scope_id: str
- path: tuple[str, ...]
- class stormlog.phases.PhaseBoundaryRecord(action: 'str', name: 'str', path: 'tuple[str, ...]', depth: 'int', scope_id: 'str', parent_scope_id: 'str | None', thread_id: 'int', thread_name: 'str', sequence: 'int', session_id: 'str', timestamp_ns: 'int', attributes: 'dict[str, Any]')[source]
Bases:
object- Parameters:
action (str)
name (str)
path (tuple[str, ...])
depth (int)
scope_id (str)
parent_scope_id (str | None)
thread_id (int)
thread_name (str)
sequence (int)
session_id (str)
timestamp_ns (int)
attributes (dict[str, Any])
- action: str
- name: str
- path: tuple[str, ...]
- depth: int
- scope_id: str
- parent_scope_id: str | None
- thread_id: int
- thread_name: str
- sequence: int
- session_id: str
- timestamp_ns: int
- attributes: dict[str, Any]
- class stormlog.phases.PhaseHandle(*, scope_id, name, path, close_callback)[source]
Bases:
objectA closeable tracker phase handle returned by
enter_phase().- Parameters:
scope_id (str)
name (str)
path (tuple[str, ...])
close_callback (Callable[[], Any])
- property phase_path: str
Return the formatted phase path.
- property closed: bool
Return
Trueonce the handle has been closed.
- exception stormlog.phases.PhaseProtocolError[source]
Bases:
RuntimeErrorRaised when phase handles are closed incorrectly.
- class stormlog.phases.PhaseRecorder[source]
Bases:
objectPer-tracker phase nesting state and boundary payload generation.
- enter(*, session_id, rank, name, attrs=None)[source]
Primary runtime API returning both a token and the emitted boundary.
- Parameters:
session_id (str)
rank (int)
name (str)
attrs (Mapping[str, Any] | None)
- Return type:
tuple[PhaseToken, PhaseBoundary]
- enter_phase(*, session_id, rank, name, metadata=None)[source]
Register one nested phase enter transition.
- Parameters:
session_id (str)
rank (int)
name (str)
metadata (Mapping[str, Any] | None)
- Return type:
- exit(token)[source]
Primary runtime API for strict token-based exit.
- Parameters:
token (PhaseToken)
- Return type:
- class stormlog.phases.PhaseReplayIndex(intervals_by_group)[source]
Bases:
objectReplay phase boundaries into queryable active spans.
- Parameters:
intervals_by_group (Mapping[tuple[str, int], Sequence[PhaseSpan]])
- classmethod from_events(events)[source]
Build a replay index from telemetry events.
- Parameters:
events (Sequence[Any])
- Return type:
- spans_for(*, session_id, rank=None)[source]
Return all reconstructed spans for one session/rank selection.
- Parameters:
session_id (str)
rank (int | None)
- Return type:
list[PhaseSpan]
- active_spans(*, timestamp_ns, session_id, rank=None)[source]
Return active spans at a timestamp before attribution policy is applied.
- Parameters:
timestamp_ns (int)
session_id (str)
rank (int | None)
- Return type:
list[PhaseSpan]
- resolve(*, timestamp_ns, session_id, rank=None, origin_thread_id=None, origin_phase_scope_id=None)[source]
Resolve one timestamp against the replay index.
- Parameters:
timestamp_ns (int)
session_id (str | None)
rank (int | None)
origin_thread_id (int | None)
origin_phase_scope_id (str | None)
- Return type:
Any
- class stormlog.phases.PhaseSpan(session_id: 'str', rank: 'int', thread_id: 'int', thread_name: 'str', scope_id: 'str', path: 'tuple[str, ...]', start_ns: 'int', end_ns: 'int', sequence: 'int', synthetic_end: 'bool' = False)[source]
Bases:
object- Parameters:
session_id (str)
rank (int)
thread_id (int)
thread_name (str)
scope_id (str)
path (tuple[str, ...])
start_ns (int)
end_ns (int)
sequence (int)
synthetic_end (bool)
- session_id: str
- rank: int
- thread_id: int
- thread_name: str
- scope_id: str
- path: tuple[str, ...]
- start_ns: int
- end_ns: int
- sequence: int
- synthetic_end: bool = False
- property depth: int
- class stormlog.phases.PhaseToken(scope_id, session_id, rank, thread_id, name)[source]
Bases:
objectOpaque runtime token used for strict phase exit semantics.
- Parameters:
scope_id (str)
session_id (str)
rank (int)
thread_id (int)
name (str)
- scope_id: str
- session_id: str
- rank: int
- thread_id: int
- name: str
- stormlog.phases.phase_attribution_to_payload(attribution)[source]
Serialize a phase attribution without emitting redundant summary fields.
- Parameters:
attribution (PhaseAttribution | None)
- Return type:
dict[str, Any] | None
- stormlog.phases.resolve_phase_for_event(index, event)[source]
Resolve a phase attribution for one event-like object using replay data.
- Parameters:
index (ReplayPhaseReplayIndex)
event (Any)
- Return type:
PhaseAttribution | None
- stormlog.phases.format_phase_path(path)[source]
Return a human-readable phase path label.
- Parameters:
path (Sequence[str])
- Return type:
str
- stormlog.phases.is_phase_boundary_event(event)[source]
Return
Truewhen the event is a structured phase boundary.- Parameters:
event (Any)
- Return type:
bool
- stormlog.phases.merge_phase_attributions(first, second)[source]
Merge two attribution candidates without inventing a false unique path.
- Parameters:
first (PhaseAttribution | None)
second (PhaseAttribution | None)
- Return type:
PhaseAttribution | None
- stormlog.phases.parse_phase_boundary(event)[source]
Extract one normalized phase payload from an event-like object.
- Parameters:
event (Any)
- Return type:
PhaseBoundaryRecord | None
- stormlog.phases.summarize_phase_attribution(attribution)[source]
Return a user-facing summary string for one phase attribution.
- Parameters:
attribution (PhaseAttribution | None)
- Return type:
str | None
- stormlog.phases.summarize_phase_resolution(*, phase_resolution, phase_path=None, phase_paths=None)[source]
Render one phase resolution without hiding ambiguity semantics.
- Parameters:
phase_resolution (str | None)
phase_path (str | None)
phase_paths (Sequence[str] | None)
- Return type:
str | None
Modules
Phase attribution policy and formatting helpers. |
|
Phase boundary parsing and replay index helpers. |
|
Runtime phase state tracking and boundary payload emission. |