TermUI.Component.Introspection (TermUI v1.0.0)

View Source

Supervision 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

aggregate_stats()

@spec aggregate_stats() :: map()

Returns aggregate statistics for all components.

find_by_module(module)

@spec find_by_module(module()) :: [map()]

Finds components by module.

find_unstable(threshold \\ 1)

@spec find_unstable(non_neg_integer()) :: [map()]

Finds components with high restart counts.

Parameters

  • threshold - Minimum restart count (default: 1)

format_tree()

@spec format_tree() :: String.t()

Returns the tree as a formatted string.

get_component_info(component_id)

@spec get_component_info(term()) :: {:ok, map()} | {:error, :not_found}

Returns detailed information about a component.

Parameters

  • component_id - Component identifier

Returns

  • {:ok, info} - Component information
  • {:error, :not_found} - Component not found

get_component_tree()

@spec get_component_tree() :: [map()]

Returns the component tree structure.

Returns

A map with tree structure:

%{
  id: term(),
  pid: pid(),
  module: module(),
  children: [...]
}

get_metrics(component_id)

@spec get_metrics(term()) :: {:ok, map()} | {:error, :not_found}

Returns supervision metrics for a component.

Parameters

  • component_id - Component identifier

Returns

  • {:ok, metrics} - Metrics map
  • {:error, :not_found} - Component not found