Inspecting Supervisors at Runtime
When you have a supervision tree up and running, you may want to get some information from it at runtime. For example, how many processes are currently running under a particular supervisor, what kind of processes they are, and so on. In this section, we’ll cover two functions that will help you answer any questions you may have about the state of the supervision tree.
The first function is count_children/1, and is available in both DynamicSupervisor and Supervisor modules. It gives us information about the number of processes currently running under the given supervisor. When you call count_children/1 with a PID or a name of a supervisor process, you will get a map with the following keys and values:
-
:supervisors ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access