Stuff Goes Bad:Erlang In Anger

OTP Processes

When processes in question are OTP processes (most of the processes in a production system should definitely be OTP processes), you instantly win more tools to inspect them.  In general the sys module 23 is what you want to look into. Read the documentation
on it and you’ll discover why it’s so useful. It contains the following features for any OTP process:

 当发生问题的进程是OTP进程时(大部分产品级的系统都是OTP 进程),你就可以立即得到更多的工具来检查它们。

 • logging of all messages and state transitions, both to the shell or to a file, or even in an internal buffer to be queried;
 • statistics (reductions, message counts, time, and so on);
 • fetching the status of a process (metadata including the state);
 • fetching the state of a process (as in the #state{} record);
 • replacing that state
 • custom debugging functions to be used as callbacks
 It also provides functionality to suspend or resume process execution.
 I won’t go into a lot of details about these functions, but be aware that they exist.

 •记录了所有消息和状态转换,可以输出来shell上或指定文件中,甚至可以输出到一个内部 缓冲区(internal buffer)供查询。