TermUI.Component.Introspection (TermUI v1.0.0)
View SourceSupervision introspection tools for debugging and monitoring.
Provides visibility into the component tree structure, component states, and supervision metrics for debugging and monitoring purposes.
These functions inspect the standalone ComponentRegistry/
ComponentServer subsystem. They do not inspect the single Elm root owned by
TermUI.Runtime, and the required services must already be running.
Usage
# Get tree structure
tree = Introspection.get_component_tree()
# Get component info
info = Introspection.get_component_info(:my_component)
# Print tree visualization
Introspection.print_tree()
# Get supervision metrics
metrics = Introspection.get_metrics(:my_component)
Summary
Functions
Returns aggregate statistics for all components.
Finds components by module.
Finds components with high restart counts.
Returns the tree as a formatted string.
Returns detailed information about a component.
Returns the component tree structure.
Returns supervision metrics for a component.
Prints a text visualization of the component tree.
Functions
@spec aggregate_stats() :: map()
Returns aggregate statistics for all components.
Finds components by module.
@spec find_unstable(non_neg_integer()) :: [map()]
Finds components with high restart counts.
Parameters
threshold- Minimum restart count (default: 1)
@spec format_tree() :: String.t()
Returns the tree as a formatted string.
Returns detailed information about a component.
Parameters
component_id- Component identifier
Returns
{:ok, info}- Component information{:error, :not_found}- Component not found
@spec get_component_tree() :: [map()]
Returns the component tree structure.
Returns
A map with tree structure:
%{
id: term(),
pid: pid(),
module: module(),
children: [...]
}
Returns supervision metrics for a component.
Parameters
component_id- Component identifier
Returns
{:ok, metrics}- Metrics map{:error, :not_found}- Component not found
@spec print_tree(keyword()) :: :ok
Prints a text visualization of the component tree.
Options
:io- IO device to print to (default::stdio)