TestcontainerEx.Recon (testcontainer_ex v0.5.0)

Copy Markdown View Source

Debugging helpers powered by :recon (Erlang runtime inspection).

This module is only available in :dev and :test environments. It provides convenient Elixir wrappers around common :recon operations for inspecting the TestcontainerEx GenServer, processes, and memory.

Prerequisites

Add :recon to your dependencies (already included in dev/test):

{:recon, "~> 2.5", only: [:dev, :test]}

Usage (from iex -S mix)

# Show top processes by memory
TestcontainerEx.Recon.top_processes()

# Inspect the TestcontainerEx GenServer state
TestcontainerEx.Recon.server_state()

# Show process info for the GenServer
TestcontainerEx.Recon.server_info()

Summary

Functions

Returns memory allocation breakdown for the node.

Returns a summary of the TestcontainerEx server's tracked resources.

Returns process info for the TestcontainerEx GenServer.

Returns the current state of the TestcontainerEx GenServer.

Returns the top N processes sorted by memory usage.

Functions

memory()

@spec memory() :: [{atom(), non_neg_integer()}]

Returns memory allocation breakdown for the node.

resource_summary()

@spec resource_summary() :: map() | {:error, :not_running}

Returns a summary of the TestcontainerEx server's tracked resources.

More readable than server_state/0 — shows counts and names rather than the full state struct.

server_info()

@spec server_info() :: [{atom(), term()}] | {:error, :not_running}

Returns process info for the TestcontainerEx GenServer.

server_state()

@spec server_state() :: map() | {:error, :not_running}

Returns the current state of the TestcontainerEx GenServer.

Useful for debugging from IEx to see tracked containers, networks, and compose environments.

top_processes(n \\ 10)

@spec top_processes(pos_integer()) :: [{pid(), term()}]

Returns the top N processes sorted by memory usage.

Uses :recon.proc_windows/2 when available, falls back to a simple implementation otherwise.